/// <summary> /// Update mouse pointer based on mouse movement, moving between panels as necessary /// </summary> void UpdateMousePointer() { // Only allow mouse movement if gaze is focussed on this canvas if (inputModule.activeGraphicRaycaster != canvas.GetComponent <OVRRaycaster>()) { return; } // Move the mouse according to move speed, and move to next panel if necessary mousePos += new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")) * pointer.mouseMoveSpeed; float currentPanelWidth = currentPointerPanel.panel.GetComponent <RectTransform>().rect.width; float currentPanelHeight = currentPointerPanel.panel.GetComponent <RectTransform>().rect.height; if (mousePos.x < -currentPanelWidth / 2) { if (currentPointerPanel.leftPanel != null) { mousePos.x += currentPanelWidth / 2 + currentPointerPanel.leftPanel.panel.GetComponent <RectTransform>().rect.width / 2; SetPointerPanel(currentPointerPanel.leftPanel); } else { mousePos.x = -currentPanelWidth / 2; } } else if (mousePos.x > currentPanelWidth / 2) { if (currentPointerPanel.rightPanel != null) { mousePos.x -= currentPanelWidth / 2 + currentPointerPanel.rightPanel.panel.GetComponent <RectTransform>().rect.width / 2; SetPointerPanel(currentPointerPanel.rightPanel); } else { mousePos.x = currentPanelWidth / 2; } } mousePos.y = Mathf.Clamp(mousePos.y, -currentPanelHeight / 2, currentPanelHeight / 2); // Position mouse pointer pointer.SetLocalPosition(mousePos); }