123456789101112131415161718192021 |
- using System;
- using UnityEngine;
- public class TouchToMouse : MonoBehaviour
- {
- private void Update()
- {
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- foreach (Touch touch in Input.touches)
- {
- RaycastHit raycastHit;
- if (Physics.Raycast(ray, out raycastHit))
- {
- if (touch.phase == TouchPhase.Began)
- {
- raycastHit.transform.gameObject.SendMessage("OnMouseDown");
- }
- }
- }
- }
- }
|