Exemplo n.º 1
0
        public void ProcessEvent(EventBase evt)
        {
            IPointerEvent pe = evt as IPointerEvent;

            if (pe == null)
            {
                return;
            }

            if (evt.eventTypeId == PointerDownEvent.TypeId() && pe.button == 0)
            {
                StartClickTracking(evt);
            }
            else if (evt.eventTypeId == PointerMoveEvent.TypeId())
            {
                // Button 1 pressed while another button was already pressed.
                if (pe.button == 0 && (pe.pressedButtons & 1) == 1)
                {
                    StartClickTracking(evt);
                }
                // Button 1 released while another button is still pressed.
                else if (pe.button == 0 && (pe.pressedButtons & 1) == 0)
                {
                    SendClickEvent(evt);
                }
                // Pointer moved or other button pressed/released
                else
                {
                    var clickStatus = m_ClickStatus[pe.pointerId];
                    if (clickStatus.m_Target != null)
                    {
                        // stop the multi-click sequence on move
                        clickStatus.m_LastPointerDownTime = 0;
                    }
                }
            }
            else if (evt.eventTypeId == PointerCancelEvent.TypeId() ||
                     evt.eventTypeId == DragUpdatedEvent.TypeId()
                     )
            {
                CancelClickTracking(evt);

                // Note that we don't cancel the click when we have a PointerStationaryEvent anymore. Touch stationary
                // events are sent on each frame where the touch doesn't move, starting immediately after the frame
                // where the touch begin event occured. If we want to cancel the ClickEvent after the touch has been
                // idle for some time, then we need to manually track the duration of the stationary phase.
            }
            else if (evt.eventTypeId == PointerUpEvent.TypeId() && pe.button == 0)
            {
                SendClickEvent(evt);
            }
        }
Exemplo n.º 2
0
        public void ProcessEvent(EventBase evt)
        {
            IPointerEvent pe = evt as IPointerEvent;

            if (pe == null)
            {
                return;
            }

            if (evt.eventTypeId == PointerDownEvent.TypeId() && pe.button == 0)
            {
                StartClickTracking(evt);
            }
            else if (evt.eventTypeId == PointerMoveEvent.TypeId())
            {
                // Button 1 pressed while another button was already pressed.
                if (pe.button == 0 && (pe.pressedButtons & 1) == 1)
                {
                    StartClickTracking(evt);
                }
                // Button 1 released while another button is still pressed.
                else if (pe.button == 0 && (pe.pressedButtons & 1) == 0)
                {
                    SendClickEvent(evt);
                }
                // Pointer moved or other button pressed/released
                else
                {
                    var clickStatus = m_ClickStatus[pe.pointerId];
                    if (clickStatus.m_Target != null)
                    {
                        // stop the multi-click sequence on move
                        clickStatus.m_LastPointerDownTime = 0;
                    }
                }
            }
            else if (evt.eventTypeId == PointerCancelEvent.TypeId() ||
                     evt.eventTypeId == PointerStationaryEvent.TypeId()
#if UNITY_EDITOR
                     || evt.eventTypeId == DragUpdatedEvent.TypeId()
#endif
                     )
            {
                CancelClickTracking(evt);
            }
            else if (evt.eventTypeId == PointerUpEvent.TypeId() && pe.button == 0)
            {
                SendClickEvent(evt);
            }
        }