예제 #1
0
        protected override void ProcessDrag(PointerEventData pointerEvent)
        {
            Vector2 position = pointerEvent.position;
            bool    flag     = OVRInputModule.IsPointerMoving(pointerEvent);

            if (flag && pointerEvent.pointerDrag != null && !pointerEvent.dragging && this.ShouldStartDrag(pointerEvent))
            {
                if (pointerEvent.IsVRPointer())
                {
                    pointerEvent.position = this.SwipeAdjustedPosition(position, pointerEvent);
                }
                ExecuteEvents.Execute <IBeginDragHandler>(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.beginDragHandler);
                pointerEvent.dragging = true;
            }
            if (pointerEvent.dragging && flag && pointerEvent.pointerDrag != null)
            {
                if (pointerEvent.IsVRPointer())
                {
                    pointerEvent.position = this.SwipeAdjustedPosition(position, pointerEvent);
                }
                if (pointerEvent.pointerPress != pointerEvent.pointerDrag)
                {
                    ExecuteEvents.Execute <IPointerUpHandler>(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler);
                    pointerEvent.eligibleForClick = false;
                    pointerEvent.pointerPress     = null;
                    pointerEvent.rawPointerPress  = null;
                }
                ExecuteEvents.Execute <IDragHandler>(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.dragHandler);
            }
        }
예제 #2
0
        private void ProcessMouseEvent(PointerInputModule.MouseState mouseData)
        {
            bool pressed  = mouseData.AnyPressesThisFrame();
            bool released = mouseData.AnyReleasesThisFrame();

            PointerInputModule.MouseButtonEventData eventData = mouseData.GetButtonState(PointerEventData.InputButton.Left).eventData;
            if (!OVRInputModule.UseMouse(pressed, released, eventData.buttonData))
            {
                return;
            }
            this.ProcessMousePress(eventData);
            this.ProcessMove(eventData.buttonData);
            this.ProcessDrag(eventData.buttonData);
            this.ProcessMousePress(mouseData.GetButtonState(PointerEventData.InputButton.Right).eventData);
            this.ProcessDrag(mouseData.GetButtonState(PointerEventData.InputButton.Right).eventData.buttonData);
            this.ProcessMousePress(mouseData.GetButtonState(PointerEventData.InputButton.Middle).eventData);
            this.ProcessDrag(mouseData.GetButtonState(PointerEventData.InputButton.Middle).eventData.buttonData);
            if (!Mathf.Approximately(eventData.buttonData.scrollDelta.sqrMagnitude, 0f))
            {
                GameObject eventHandler = ExecuteEvents.GetEventHandler <IScrollHandler>(eventData.buttonData.pointerCurrentRaycast.gameObject);
                ExecuteEvents.ExecuteHierarchy <IScrollHandler>(eventHandler, eventData.buttonData, ExecuteEvents.scrollHandler);
            }
        }
예제 #3
0
        protected virtual PointerInputModule.MouseState GetGazePointerData()
        {
            OVRPointerEventData ovrpointerEventData;

            this.GetPointerData(-1, out ovrpointerEventData, true);
            ovrpointerEventData.Reset();
            ovrpointerEventData.worldSpaceRay    = new Ray(this.rayTransform.position, this.rayTransform.forward);
            ovrpointerEventData.scrollDelta      = this.GetExtraScrollDelta();
            ovrpointerEventData.button           = PointerEventData.InputButton.Left;
            ovrpointerEventData.useDragThreshold = true;
            base.eventSystem.RaycastAll(ovrpointerEventData, this.m_RaycastResultCache);
            RaycastResult raycastResult = BaseInputModule.FindFirstRaycast(this.m_RaycastResultCache);

            ovrpointerEventData.pointerCurrentRaycast = raycastResult;
            this.m_RaycastResultCache.Clear();
            OVRRaycaster ovrraycaster = raycastResult.module as OVRRaycaster;

            if (ovrraycaster)
            {
                ovrpointerEventData.position = ovrraycaster.GetScreenPosition(raycastResult);
                RectTransform component = raycastResult.gameObject.GetComponent <RectTransform>();
                if (component != null)
                {
                    Vector3 worldPosition       = raycastResult.worldPosition;
                    Vector3 rectTransformNormal = OVRInputModule.GetRectTransformNormal(component);
                    OVRGazePointer.instance.SetPosition(worldPosition, rectTransformNormal);
                    OVRGazePointer.instance.RequestShow();
                }
            }
            OVRPhysicsRaycaster ovrphysicsRaycaster = raycastResult.module as OVRPhysicsRaycaster;

            if (ovrphysicsRaycaster)
            {
                Vector3 worldPosition2 = raycastResult.worldPosition;
                if (this.performSphereCastForGazepointer)
                {
                    List <RaycastResult> list = new List <RaycastResult>();
                    ovrphysicsRaycaster.Spherecast(ovrpointerEventData, list, OVRGazePointer.instance.GetCurrentRadius());
                    if (list.Count > 0 && list[0].distance < raycastResult.distance)
                    {
                        worldPosition2 = list[0].worldPosition;
                    }
                }
                ovrpointerEventData.position = ovrphysicsRaycaster.GetScreenPos(raycastResult.worldPosition);
                OVRGazePointer.instance.RequestShow();
                if (this.matchNormalOnPhysicsColliders)
                {
                    OVRGazePointer.instance.SetPosition(worldPosition2, raycastResult.worldNormal);
                }
                else
                {
                    OVRGazePointer.instance.SetPosition(worldPosition2);
                }
            }
            OVRPointerEventData ovrpointerEventData2;

            this.GetPointerData(-2, out ovrpointerEventData2, true);
            this.CopyFromTo(ovrpointerEventData, ovrpointerEventData2);
            ovrpointerEventData2.button = PointerEventData.InputButton.Right;
            OVRPointerEventData ovrpointerEventData3;

            this.GetPointerData(-3, out ovrpointerEventData3, true);
            this.CopyFromTo(ovrpointerEventData, ovrpointerEventData3);
            ovrpointerEventData3.button = PointerEventData.InputButton.Middle;
            this.m_MouseState.SetButtonState(PointerEventData.InputButton.Left, this.GetGazeButtonState(), ovrpointerEventData);
            this.m_MouseState.SetButtonState(PointerEventData.InputButton.Right, PointerEventData.FramePressState.NotChanged, ovrpointerEventData2);
            this.m_MouseState.SetButtonState(PointerEventData.InputButton.Middle, PointerEventData.FramePressState.NotChanged, ovrpointerEventData3);
            return(this.m_MouseState);
        }
예제 #4
0
 private static bool UseMouse(bool pressed, bool released, PointerEventData pointerData)
 {
     return(pressed || released || OVRInputModule.IsPointerMoving(pointerData) || pointerData.IsScrolling());
 }
예제 #5
0
 new void Awake()
 {
     LastInstance = this;
 }