Ejemplo n.º 1
0
        private bool ProcessFingerEvents()
        {
            bool result = false;

            var fingers = XREventSystem.GetFingers();
            int length  = fingers.Count;

            for (int i = 0; !result && i < length; i++)
            {
                var finger = fingers[i];
                if (!finger.isActiveAndEnabled)
                {
                    continue;
                }

                bool released;
                bool pressed;
                var  pointer = GetFingerPointerEventData(finger, out pressed, out released);

                //处理按压逻辑。这里会记录按下的位置pressPosition
                ProcessTouchPress(pointer, pressed, released);
                //由于Fingger 的position为固定值,所以需要从新记录为worldPosition
                if (pressed)
                {
                    RecordPressedPosition(pointer);
                }

                if (!released)
                {
                    ProcessXRPointerMove(pointer);
                    ProcessDrag(pointer);
                }
                else
                {
                    RemovePointerData(pointer);
                }

                result = finger.available || result;
            }
            return(result);
        }
Ejemplo n.º 2
0
        private bool ProcessLaserEvents()
        {
            bool result = false;

            var lasers = XREventSystem.GetLasers();
            int length = lasers.Count;

            for (int i = 0; i < length; i++)
            {
                var laser = lasers[i];
                if (!laser.isActiveAndEnabled)
                {
                    continue;
                }

                var mouseButtonData = GetLaserPointerEventData(laser);

                //处理按压逻辑。这里会记录按下的位置pressPosition
                ProcessMousePress(mouseButtonData);
                //由于Laser的position为固定值,所以需要从新记录为worldPosition
                if (mouseButtonData.PressedThisFrame())
                {
                    RecordPressedPosition(mouseButtonData.buttonData as XRPointEventData);
                }

                ProcessXRPointerMove(mouseButtonData.buttonData);
                ProcessDrag(mouseButtonData.buttonData);

                m_CurrentFocusedObject = mouseButtonData.buttonData.pointerCurrentRaycast.gameObject;

                if (!Mathf.Approximately(mouseButtonData.buttonData.scrollDelta.sqrMagnitude, 0.0f))
                {
                    var scrollHandler = ExecuteEvents.GetEventHandler <IScrollHandler>(mouseButtonData.buttonData.pointerCurrentRaycast.gameObject);
                    ExecuteEvents.ExecuteHierarchy(scrollHandler, mouseButtonData.buttonData, ExecuteEvents.scrollHandler);
                }

                result = true;
            }
            return(result);
        }
Ejemplo n.º 3
0
 protected override void OnDisable()
 {
     XREventSystem.Remove(this);
     base.OnDisable();
 }
Ejemplo n.º 4
0
 protected override void OnEnable()
 {
     base.OnEnable();
     XREventSystem.Regist(this);
 }