public void CheckKeyboardAndMouse() { if (Input.GetKeyDown(m_manager.KeyboardShow)) { VdmDesktopManager.ActionInThisFrame = true; m_lastShowClickStart = Time.time; if (Visible() == false) { Show(); m_lastShowClickStart -= 10; // Avoid quick show/close } } if (Input.GetKey(m_manager.KeyboardShow)) { VdmDesktopManager.ActionInThisFrame = true; m_manager.KeyboardDistance += Input.GetAxisRaw("Mouse ScrollWheel"); m_manager.KeyboardDistance = Mathf.Clamp(m_manager.KeyboardDistance, 0.2f, 100); m_positionNormal = Camera.main.transform.position + Camera.main.transform.rotation * new Vector3(0, 0, m_manager.KeyboardDistance); m_positionNormal += m_manager.MultiMonitorPositionOffset * ScreenIndex; m_rotationNormal = Camera.main.transform.rotation; } if (Input.GetKeyUp(m_manager.KeyboardShow)) { VdmDesktopManager.ActionInThisFrame = true; if (Time.time - m_lastShowClickStart < 0.5f) { m_lastShowClickStart = 0; Hide(); } } if (m_manager.KeyboardZoom != KeyCode.None) { if (Input.GetKeyDown(m_manager.KeyboardZoom)) { if (m_zoom == false) { m_zoomWithFollowCursor = true; ZoomIn(); } else { ZoomOut(); } } if ((m_zoom) && (m_zoomWithFollowCursor)) { VdmDesktopManager.ActionInThisFrame = true; m_manager.KeyboardZoomDistance += Input.GetAxisRaw("Mouse ScrollWheel"); m_manager.KeyboardZoomDistance = Mathf.Clamp(m_manager.KeyboardZoomDistance, 0.2f, 100); // Cursor position in world space Vector3 cursorPos = m_manager.GetCursorPos(); cursorPos.x = cursorPos.x / m_manager.GetScreenWidth(Screen); cursorPos.y = cursorPos.y / m_manager.GetScreenHeight(Screen); cursorPos.y = 1 - cursorPos.y; cursorPos.x = cursorPos.x - 0.5f; cursorPos.y = cursorPos.y - 0.5f; cursorPos = transform.TransformPoint(cursorPos); Vector3 deltaCursor = transform.position - cursorPos; m_positionZoomed = Camera.main.transform.position + Camera.main.transform.rotation * new Vector3(0, 0, m_manager.KeyboardZoomDistance); m_positionZoomed += m_manager.MultiMonitorPositionOffset * ScreenIndex; m_rotationZoomed = Camera.main.transform.rotation; m_positionZoomed += deltaCursor; } } }
public void CheckKeyboardAndMouse() { /* * if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstick)) * { * VdmDesktopManager.ActionInThisFrame = true; * * m_lastShowClickStart = Time.time; * * if (Visible() == false) * { * if (TGraph.GlobalVariables.Graph.selectedNodes.Count > 0 && TGraph.GlobalVariables.Graph.latestSelection!= curSelection ) * { * curSelection = TGraph.GlobalVariables.Graph.latestSelection; * // Debug.Log("link:" + TGraph.GlobalVariables.Graph.nodes[TGraph.GlobalVariables.Graph.latestSelection].url); * Application.OpenURL("https://mmt.mathhub.info" + TGraph.GlobalVariables.Graph.nodes[TGraph.GlobalVariables.Graph.latestSelection].url); * } * * Show(); * m_lastShowClickStart -= 10; // Avoid quick show/close * } * } * * if (OVRInput.Get(OVRInput.Button.PrimaryThumbstick)) * { * VdmDesktopManager.ActionInThisFrame = true; * * m_manager.KeyboardDistance += Input.GetAxisRaw("Mouse ScrollWheel"); * m_manager.KeyboardDistance = Mathf.Clamp(m_manager.KeyboardDistance, 0.2f, 100); * * m_positionNormal = Camera.main.transform.position + Camera.main.transform.rotation * new Vector3(0, 0, m_manager.KeyboardDistance); * m_positionNormal += m_manager.MultiMonitorPositionOffset * ScreenIndex; * m_rotationNormal = Camera.main.transform.rotation; * } * * if (OVRInput.GetUp(OVRInput.Button.PrimaryThumbstick)) * { * VdmDesktopManager.ActionInThisFrame = true; * * if (Time.time - m_lastShowClickStart < 0.5f) * { * m_lastShowClickStart = 0; * * Hide(); * } * * }*/ if (m_manager.KeyboardZoom != KeyCode.None) { if (Input.GetKeyDown(m_manager.KeyboardZoom)) { if (m_zoom == false) { m_zoomWithFollowCursor = true; ZoomIn(); } else { ZoomOut(); } } if ((m_zoom) && (m_zoomWithFollowCursor)) { VdmDesktopManager.ActionInThisFrame = true; m_manager.KeyboardZoomDistance += Input.GetAxisRaw("Mouse ScrollWheel"); m_manager.KeyboardZoomDistance = Mathf.Clamp(m_manager.KeyboardZoomDistance, 0.2f, 100); // Cursor position in world space Vector3 cursorPos = m_manager.GetCursorPos(); cursorPos.x = cursorPos.x / m_manager.GetScreenWidth(Screen); cursorPos.y = cursorPos.y / m_manager.GetScreenHeight(Screen); cursorPos.y = 1 - cursorPos.y; cursorPos.x = cursorPos.x - 0.5f; cursorPos.y = cursorPos.y - 0.5f; cursorPos = transform.TransformPoint(cursorPos); Vector3 deltaCursor = transform.position - cursorPos; m_positionZoomed = Camera.main.transform.position + Camera.main.transform.rotation * new Vector3(0, 0, m_manager.KeyboardZoomDistance); m_positionZoomed += m_manager.MultiMonitorPositionOffset * ScreenIndex; m_rotationZoomed = Camera.main.transform.rotation; m_positionZoomed += deltaCursor; } } }