protected static FindFirstRaycast ( List |
||
candidates | List |
|
리턴 |
/// <summary> /// <para>Return the current MouseState.</para> /// </summary> /// <param name="id"></param> protected virtual PointerInputModule.MouseState GetMousePointerEventData(int id) { PointerEventData data1; bool pointerData = this.GetPointerData(-1, out data1, true); data1.Reset(); if (pointerData) { data1.position = (Vector2)Input.mousePosition; } Vector2 mousePosition = (Vector2)Input.mousePosition; data1.delta = mousePosition - data1.position; data1.position = mousePosition; data1.scrollDelta = Input.mouseScrollDelta; data1.button = PointerEventData.InputButton.Left; this.eventSystem.RaycastAll(data1, this.m_RaycastResultCache); RaycastResult firstRaycast = BaseInputModule.FindFirstRaycast(this.m_RaycastResultCache); data1.pointerCurrentRaycast = firstRaycast; this.m_RaycastResultCache.Clear(); PointerEventData data2; this.GetPointerData(-2, out data2, true); this.CopyFromTo(data1, data2); data2.button = PointerEventData.InputButton.Right; PointerEventData data3; this.GetPointerData(-3, out data3, true); this.CopyFromTo(data1, data3); data3.button = PointerEventData.InputButton.Middle; this.m_MouseState.SetButtonState(PointerEventData.InputButton.Left, PointerInputModule.StateForMouseButton(0), data1); this.m_MouseState.SetButtonState(PointerEventData.InputButton.Right, PointerInputModule.StateForMouseButton(1), data2); this.m_MouseState.SetButtonState(PointerEventData.InputButton.Middle, PointerInputModule.StateForMouseButton(2), data3); return(this.m_MouseState); }
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); }