Bootstrap

unity 用EasyTouch 旋转模型限定滑动区域

今天用 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);
            }
            }
;