示例#1
0
    public void OnEndDrag(PointerEventData e)
    {
        if (_direction.x == 1)
        {
            float deltaX = e.position.x - e.pressPosition.x;
            if (_timer <= QUICKDRAG_TIME && Mathf.Abs(deltaX) > Screen.width * QUICKDRAG_DIST)
            {
                if (deltaX > 0)
                {
                    _controller.LeftMenu();
                }
                else
                {
                    _controller.RightMenu();
                }
            }
            else if (e.position.x < Screen.width * LONGDRAG_MIN_X && Mathf.Abs(deltaX) > Screen.width * LONGDRAG_DIST)
            {
                _controller.RightMenu();
            }
            else if (e.position.x > Screen.width * (1f - LONGDRAG_MIN_X) && Mathf.Abs(deltaX) > Screen.width * LONGDRAG_DIST)
            {
                _controller.LeftMenu();
            }
            else
            {
                _controller.ResetMenu();
            }
        }

        _dragging  = false;
        _direction = Vector2.zero;
        _timer     = 0;
    }