Пример #1
0
        private void ProcessRelease(HVRUIPointer pointer)
        {
            var eventData = pointer.PointerEventData;

            ExecuteEvents.Execute(eventData.pointerPress, eventData, ExecuteEvents.pointerUpHandler);

            var handler = ExecuteEvents.GetEventHandler <IPointerClickHandler>(pointer.CurrentUIElement);

            if (eventData.pointerPress == handler && eventData.eligibleForClick)
            {
                ExecuteEvents.Execute(eventData.pointerPress, eventData, ExecuteEvents.pointerClickHandler);
            }
            else if (eventData.pointerDrag != null)
            {
                ExecuteEvents.ExecuteHierarchy(pointer.CurrentUIElement, eventData, ExecuteEvents.dropHandler);
            }

            if (eventData.pointerDrag != null && eventData.dragging)
            {
                ExecuteEvents.Execute(eventData.pointerDrag, eventData, ExecuteEvents.endDragHandler);
            }

            eventData.eligibleForClick = false;
            eventData.dragging         = false;
            eventData.pointerDrag      = null;
            eventData.pressPosition    = Vector2.zero;
            eventData.pointerPress     = null;
            eventData.rawPointerPress  = null;

            if (pointer.CurrentUIElement != eventData.pointerEnter)
            {
                HandlePointerExitAndEnter(eventData, null);
                HandlePointerExitAndEnter(eventData, pointer.CurrentUIElement);
            }
        }
Пример #2
0
        private void ProcessPress(HVRUIPointer pointer)
        {
            var eventData = pointer.PointerEventData;

            eventData.eligibleForClick    = true;
            eventData.delta               = Vector2.zero;
            eventData.dragging            = false;
            eventData.useDragThreshold    = true;
            eventData.pressPosition       = eventData.position;
            eventData.pointerPressRaycast = eventData.pointerCurrentRaycast;

            DeselectIfSelectionChanged(pointer.CurrentUIElement, eventData);

            var pressed = ExecuteEvents.ExecuteHierarchy(pointer.CurrentUIElement, eventData, ExecuteEvents.pointerDownHandler);

            if (pressed == null)
            {
                pressed = ExecuteEvents.GetEventHandler <IPointerClickHandler>(pointer.CurrentUIElement);
            }

            eventData.pointerPress    = pressed;
            eventData.rawPointerPress = pointer.CurrentUIElement;
            eventData.clickTime       = Time.unscaledTime;
            eventData.pointerDrag     = ExecuteEvents.GetEventHandler <IDragHandler>(pointer.CurrentUIElement);
            if (eventData.pointerDrag != null)
            {
                ExecuteEvents.Execute(eventData.pointerDrag, eventData, ExecuteEvents.initializePotentialDrag);
            }
        }
Пример #3
0
        public void AddPointer(HVRUIPointer pointer)
        {
            if (Pointers == null)
            {
                Pointers = new List <HVRUIPointer>();
            }

            if (!Pointers.Contains(pointer))
            {
                Pointers.Add(pointer);
                pointer.PointerEventData = new PointerEventData(eventSystem);
            }
        }
Пример #4
0
        public void RemovePointer(HVRUIPointer pointer)
        {
            if (Pointers == null)
            {
                return;
            }

            if (Pointers.Contains(pointer))
            {
                HandlePointerExitAndEnter(pointer.PointerEventData, null);
                RemovePointerData(pointer.PointerEventData);
                Pointers.Remove(pointer);

                if (Pointers.Count == 0)
                {
                    Pointers = null;
                }
            }
        }