using System; using UnityEngine; using UnityEngine.EventSystems; namespace UnityTest.ZXL { public class Rotate : MonoBehaviour, IPointerDownHandler, IPointerUpHandler { public Transform go; public bool isLeftRotate; private bool isRotate; private Vector3 _vector3 = new Vector3(0, 1, 0); public void OnPointerDown(PointerEventData eventData) { isRotate = true; } public void OnPointerUp(PointerEventData eventData) { isRotate = false; } private void Update() { if (!isRotate) { return; } if (isLeftRotate) { go.eulerAngles += _vector3; } else { go.eulerAngles -= _vector3; } } } }