예제 #1
0
    void Update()
    {
        _dragManager.UncheckedAll();

                #if UNITY_STANDALONE || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_OSX || UNITY_EDITOR || UNITY_WEBPLAYER || UNITY_FLASH || UNITY_WEBGL
        #region Mouse Interpreter
        if (Input.GetMouseButton(0))
        {
            Vector2 pos = Input.mousePosition;
            //pos.y = Screen.height - pos.y;
            if (EventSystem.current == null || !EventSystem.current.IsPointerOverGameObject())
            {
                _dragManager.NotifyMouseDrag(pos);
            }
            else
            {
                _dragManager.CancelMouseDrag(pos);
            }
        }
        #endregion Mouse Interpreter
                #endif

        foreach (var touch in Input.touches)
        {
            Vector2 pos = touch.position;
            //pos.y = Screen.height - pos.y;
            if (EventSystem.current == null || !EventSystem.current.IsPointerOverGameObject(touch.fingerId))
            {
                _dragManager.NotifyDrag(touch.fingerId, pos);
            }
            else
            {
                _dragManager.CancelDrag(touch.fingerId, pos);
            }
        }

        var endedDrags = _dragManager.VerifyUnchecked();

        foreach (var drag in endedDrags)
        {
            if (drag.LifeTime <= _clickTime && drag.Distance <= _clickMaxDist)
            {
                TapGesture firstTap = FirstTapIfImDouble(drag.LastPoint);
                TapGesture tap      = null;

                if (firstTap != null)
                {
                    tap = new DoubleTapGesture(drag.LastPoint, firstTap);
                    _possibleDoubleTaps.Remove(firstTap);
                }
                else
                {
                    tap = new TapGesture(drag.LastPoint);
                    _possibleDoubleTaps.Add(tap);
                }

                foreach (var listener in TapEvents.Subscribers)
                {
                    if (listener(tap))
                    {
                        break;
                    }
                }
            }
        }

        _dragManager.VerifyPinch(Debug);
    }