Ejemplo n.º 1
0
        public void OnDrag(PointerEventData eventData)
        {
            var position = this.getPointPosition(eventData);

            this._windowAdapter.postPointerEvent(new PointerData(
                                                     timeStamp: Timer.timespanSinceStartup,
                                                     change: PointerChange.move,
                                                     kind: InputUtils.getPointerDeviceKind(eventData),
                                                     device: InputUtils.getPointerDeviceKey(eventData),
                                                     physicalX: position.x,
                                                     physicalY: position.y
                                                     ));
        }
Ejemplo n.º 2
0
 void handleMouseScroll()
 {
     if (Input.mouseScrollDelta.y != 0 || Input.mouseScrollDelta.x != 0)
     {
         var scaleFactor = this.canvas.scaleFactor;
         var pos         = this.getPointPosition(Input.mousePosition);
         this._windowAdapter.onScroll(Input.mouseScrollDelta.x * scaleFactor,
                                      Input.mouseScrollDelta.y * scaleFactor,
                                      pos.x,
                                      pos.y,
                                      InputUtils.getScrollButtonKey());
     }
 }
Ejemplo n.º 3
0
        public void OnPointerExit(PointerEventData eventData)
        {
            this._mouseEntered = false;
            var position = this.getPointPosition(eventData);

            this._windowAdapter.postPointerEvent(new PointerData(
                                                     timeStamp: Timer.timespanSinceStartup,
                                                     change: PointerChange.hover,
                                                     kind: InputUtils.getPointerDeviceKind(),
                                                     device: InputUtils.getPointerDeviceKey(eventData),
                                                     physicalX: position.x,
                                                     physicalY: position.y
                                                     ));
        }
Ejemplo n.º 4
0
        public void OnPointerDown(PointerEventData eventData)
        {
            EventSystem.current.SetSelectedGameObject(this.gameObject, eventData);
            var position = this.getPointPosition(eventData);

            this._windowAdapter.postPointerEvent(new PointerData(
                                                     timeStamp: Timer.timespanSinceStartup,
                                                     change: PointerChange.down,
                                                     kind: InputUtils.getPointerDeviceKind(),
                                                     device: InputUtils.getPointerDeviceKey(eventData),
                                                     physicalX: position.x,
                                                     physicalY: position.y
                                                     ));
        }
Ejemplo n.º 5
0
        public void OnPointerExit(PointerEventData eventData) {
            var pointerKey = InputUtils.getPointerDeviceKey(eventData);
            this._enteredPointers.Remove(pointerKey);

            var position = this.getPointPosition(eventData);
            this._windowAdapter.postPointerEvent(new PointerData(
                timeStamp: Timer.timespanSinceStartup,
                change: PointerChange.hover,
                kind: InputUtils.getPointerDeviceKind(eventData),
                device: pointerKey,
                physicalX: position.x,
                physicalY: position.y
            ));
        }
Ejemplo n.º 6
0
        int getMouseButtonDown()
        {
            //default mouse button key = left mouse button
            var defaultKey = 0;

            for (int key = 0; key < mouseButtonNum; key++)
            {
                if (Input.GetMouseButton(key))
                {
                    defaultKey = key;
                    break;
                }
            }
            return(InputUtils.getMouseButtonKey(defaultKey));
        }
Ejemplo n.º 7
0
        public void OnPointerUp(PointerEventData eventData)
        {
            var position = this.getPointPosition(eventData);

            if (position == null)
            {
                return;
            }
            this._windowAdapter.postPointerEvent(new PointerData(
                                                     timeStamp: Timer.timespanSinceStartup,
                                                     change: PointerChange.up,
                                                     kind: InputUtils.getPointerDeviceKind(eventData),
                                                     device: InputUtils.getPointerDeviceKey(eventData),
                                                     physicalX: position.Value.x,
                                                     physicalY: position.Value.y
                                                     ));
        }
Ejemplo n.º 8
0
        void handleTouchMove()
        {
            for (var touchIndex = 0; touchIndex < Input.touchCount; touchIndex++)
            {
                var touchEvent = Input.GetTouch(touchIndex);
                if (touchEvent.phase != TouchPhase.Moved)
                {
                    continue;
                }

                var pos = this.getPointPosition(touchEvent.position);
                this._windowAdapter.postPointerEvent(new PointerData(
                                                         timeStamp: Timer.timespanSinceStartup,
                                                         change: PointerChange.hover,
                                                         kind: PointerDeviceKind.touch,
                                                         device: InputUtils.getTouchFingerKey(touchEvent.fingerId),
                                                         physicalX: pos.x,
                                                         physicalY: pos.y
                                                         ));
            }
        }
Ejemplo n.º 9
0
        public void OnPointerEnter(PointerEventData eventData)
        {
            var position = this.getPointPosition(eventData);

            if (position == null)
            {
                return;
            }
            var pointerKey = InputUtils.getPointerDeviceKey(eventData);

            this._enteredPointers.Add(pointerKey);

            this._lastMouseMove = eventData.position;
            this._windowAdapter.postPointerEvent(new PointerData(
                                                     timeStamp: Timer.timespanSinceStartup,
                                                     change: PointerChange.hover,
                                                     kind: InputUtils.getPointerDeviceKind(eventData),
                                                     device: pointerKey,
                                                     physicalX: position.Value.x,
                                                     physicalY: position.Value.y
                                                     ));
        }