47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.EventSystems;
|
|
/// <summary>
|
|
/// 顺时针或者逆时针运动的控制类
|
|
/// </summary>
|
|
namespace ZXK.GYJQR
|
|
{
|
|
public class ClockWiseControl : MonoBehaviour
|
|
{
|
|
public AdjustAngleType angleType = AdjustAngleType.none;//调整角度枚举
|
|
public UnityEvent<AdjustAngleType, string> onMouseDown, onMouseUp;//鼠标按下,鼠标抬起
|
|
private bool _isDown = false;
|
|
private void Update()
|
|
{
|
|
if (!CG.UTility.PopUpMng._TriAble) return;
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
RaycastHit hit;//碰撞点
|
|
if (Physics.Raycast(ray.origin, ray.direction, out hit))
|
|
{
|
|
if (hit.transform.gameObject.name.Equals(transform.name))
|
|
{
|
|
_isDown = true;
|
|
}
|
|
}
|
|
}
|
|
#region 鼠标一直按下
|
|
if (Input.GetMouseButton(0))
|
|
{
|
|
if (_isDown)
|
|
{
|
|
onMouseDown?.Invoke(angleType, StepManager.Instance.CurAZBSState);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 鼠标抬起
|
|
if (Input.GetMouseButtonUp(0))
|
|
{
|
|
_isDown = false;
|
|
onMouseUp?.Invoke(angleType, StepManager.Instance.CurAZBSState);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
} |