Esempio n. 1
0
 private void PrintInputState()
 {
     Debug.LogFormat("istouching:{0} getbutton app:{1} trigger:{2} home:{3} \n" +
                     "getbuttondown app:{4} trigger:{5} home:{6} \n" +
                     "getbuttonup app:{7} trigger:{8} home:{9} \n" +
                     "origin touch:[{10}] gettouch:{11}", NRInput.IsTouching(), NRInput.GetButton(ControllerButton.APP), NRInput.GetButton(ControllerButton.TRIGGER), NRInput.GetButton(ControllerButton.HOME)
                     , NRInput.GetButtonDown(ControllerButton.APP), NRInput.GetButtonDown(ControllerButton.TRIGGER), NRInput.GetButtonDown(ControllerButton.HOME)
                     , NRInput.GetButtonUp(ControllerButton.APP), NRInput.GetButtonUp(ControllerButton.TRIGGER), NRInput.GetButtonUp(ControllerButton.HOME)
                     , NRVirtualDisplayer.SystemButtonState.ToString(), NRInput.GetTouch(m_CurrentDebugHand).ToString("F3"));
 }
        public void Update()
        {
            Swipe = SwipeDirection.None;

            if (NRInput.IsTouching())
            {
                if (Mathf.Abs(_startTime) < float.Epsilon)
                {
                    _startTime     = Time.time;
                    _startPosition = NRInput.GetTouch();
                }

                _endPosition = NRInput.GetTouch();
                return;
            }

            if (Mathf.Abs(_startTime) < float.Epsilon)
            {
                return;
            }

            var direction = _endPosition - _startPosition;

            if (direction.magnitude >= _swipeDistanceThreshold)
            {
                if (Mathf.Abs(direction.x) > Mathf.Abs(direction.y))
                {
                    Swipe = direction.x < 0 ? SwipeDirection.Left : SwipeDirection.Right;
                }
                else
                {
                    Swipe = direction.y < 0 ? SwipeDirection.Down : SwipeDirection.Up;
                }
            }

            _startTime = 0f;
        }