今天用 EasyTouch 写了个旋转模型的 限定区域位置的 先记录一下 怕以后忘记了
protected override void OnInit(object data)
{
base.OnInit(data);
EasyTouch.SetEnabled(true);
EasyTouch.On_Swipe += OnDrag;
EasyTouch.On_SwipeStart += OnDoubleTap;
}
protected override void OnDisable()
{
base.OnDisable();
EasyTouch.On_Swipe -= OnDrag;
EasyTouch.On_SwipeStart -= OnDoubleTap;
}
public event CameraOpreateHandler On_SwipeStart;
bool Isa = false;
void OnDoubleTap(Gesture gest)
{
On_SwipeStart?.Invoke(gest);
if (Input.mousePosition.y > 500 && Input.mousePosition.x > 190 && Input.mousePosition.x < 420)
{
Isa = true;
}
else
{
Isa = false;
}
}
}
void OnDrag(Gesture gest)
{
if (Isa == true)
{
Vector3 v = transform.localRotation.eulerAngles;
v.y -= gest.deltaPosition.x * 20 * Time.deltaTime;
v.y -= gest.deltaPosition.y * 20 * Time.deltaTime;
transform.rotation = Quaternion.Euler(v);
}
}