32 lines
737 B
C#
32 lines
737 B
C#
|
using System;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.EventSystems;
|
|||
|
|
|||
|
namespace ZC
|
|||
|
{
|
|||
|
public class UIRotate : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
|||
|
{
|
|||
|
[SerializeField] Transform m_Target;
|
|||
|
[SerializeField] Vector3 vec = Vector3.up * 10;
|
|||
|
bool isTrue;
|
|||
|
[SerializeField] private float speed = 10;
|
|||
|
|
|||
|
public void OnPointerDown(PointerEventData eventData)
|
|||
|
{
|
|||
|
isTrue = true;
|
|||
|
}
|
|||
|
|
|||
|
public void OnPointerUp(PointerEventData eventData)
|
|||
|
{
|
|||
|
isTrue = false;
|
|||
|
}
|
|||
|
|
|||
|
private void Update()
|
|||
|
{
|
|||
|
if (isTrue)
|
|||
|
{
|
|||
|
m_Target.Rotate(vec * speed * Time.deltaTime);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|