예제 #1
0
            public static EventBase MakeEvent(TouchPhase phase, Vector2 position, EventModifiers modifiers = EventModifiers.None, MouseButton button = MouseButton.LeftMouse)
            {
                var touch = MakeDefaultTouch();

                touch.position = position;
                touch.phase    = phase;

                if (button != MouseButton.LeftMouse)
                {
                    PointerDeviceState.PressButton(touch.fingerId, (int)button);
                }

                switch (touch.phase)
                {
                case TouchPhase.Began:
                    return(PointerDownEvent.GetPooled(touch, modifiers));

                case TouchPhase.Moved:
                    return(PointerMoveEvent.GetPooled(touch, modifiers));

                case TouchPhase.Ended:
                    return(PointerUpEvent.GetPooled(touch, modifiers));

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
예제 #2
0
        private EventBase MakeTouchEvent(Touch touch, EventModifiers modifiers)
        {
            // Flip Y Coordinates.
            touch.position      = new Vector2(touch.position.x, Screen.height - touch.position.y);
            touch.rawPosition   = new Vector2(touch.rawPosition.x, Screen.height - touch.rawPosition.y);
            touch.deltaPosition = new Vector2(touch.deltaPosition.x, Screen.height - touch.deltaPosition.y);

            switch (touch.phase)
            {
            case TouchPhase.Began:
                return(PointerDownEvent.GetPooled(touch, modifiers));

            case TouchPhase.Moved:
                return(PointerMoveEvent.GetPooled(touch, modifiers));

            case TouchPhase.Stationary:
                return(PointerStationaryEvent.GetPooled(touch, modifiers));

            case TouchPhase.Ended:
                return(PointerUpEvent.GetPooled(touch, modifiers));

            case TouchPhase.Canceled:
                return(PointerCancelEvent.GetPooled(touch, modifiers));

            default:
                return(null);
            }
        }