private void _EnableNavigationFly(bool iEnable) { m_Fly = iEnable; VRInteractionNavigationElastic navigationElastic = m_Wand.GetComponent <VRInteractionNavigationElastic>(); if (navigationElastic != null) { navigationElastic.Fly = m_Fly; } VRInteractionNavigationWandJoystick navigationWandJoystick = m_Wand.GetComponent <VRInteractionNavigationWandJoystick>(); if (navigationWandJoystick != null) { navigationWandJoystick.Fly = m_Fly; } vrInteractionManager interactionMgr = vrInteractionManager.GetInstance(); for (uint i = 0, iEnd = interactionMgr.GetInteractionsNb(); i < iEnd; ++i) { vrProperty flyProp = interactionMgr.GetInteractionByIndex(i).GetProperty("Fly"); if (flyProp != null) { flyProp.SetBool(m_Fly); } } }
protected void InitializeFromActiveNavigation() { // Search for navigation interaction parameters uint interactionNb = MiddleVR.VRInteractionMgr.GetInteractionsNb(); if (interactionNb == 0) { MVRTools.Log(4, "[~] VRHeadCollision: no interaction found in Interaction Manager."); return; } bool fly = true; vrNode3D navNodeMVR = null; for (uint i = 0; i < interactionNb; ++i) { vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteractionByIndex(i); if (interaction.IsActive() && interaction.TagsContain("Navigation")) { // Get fly mode vrProperty flyProp = interaction.GetProperty("Fly"); if (flyProp != null) { fly = flyProp.GetBool(); } // Get navigation node vrProperty navNodeProp = interaction.GetProperty("NavigationNode"); if (navNodeProp != null) { navNodeMVR = MiddleVR.VRDisplayMgr.GetNode(navNodeProp.GetObject().GetName()); } break; } } if (navNodeMVR == null) { MVRTools.Log(2, "[X] VRNavigationCollision: impossible to retrieve navigation node."); return; } // Initialize parameters from found ones SetCollisionNode(GameObject.Find(CollisionNodeName)); SetNavigationNode(navNodeMVR); SetFly(fly); // Try to start the collisions Initialize(); }
private void _EnableNavigationFly(bool iEnable) { m_Fly = iEnable; vrInteractionManager interactionMgr = vrInteractionManager.GetInstance(); for (uint i = 0, iEnd = interactionMgr.GetInteractionsNb(); i < iEnd; ++i) { vrProperty flyProp = interactionMgr.GetInteractionByIndex(i).GetProperty("Fly"); if (flyProp != null) { flyProp.SetBool(m_Fly); } } }
// Update is called once per frame void Update() { //MiddleVRTools.Log("VRManagerUpdate"); if (m_isInit) { MiddleVRTools.Log(4, "[>] Unity Update - Start"); if (kernel.GetFrame() >= m_FirstFrameAfterReset + 1 && !m_isGeometrySet && !Application.isEditor) { if (!DontChangeWindowGeometry) { displayMgr.SetUnityWindowGeometry(); } m_isGeometrySet = true; } kernel.Update(); UpdateInput(); if (ShowFPS) { guiText.text = kernel.GetFPS().ToString("f2"); } MiddleVRTools.UpdateNodes(); if (m_displayLog) { string txt = kernel.GetLogString(true); print(txt); m_GUI.text = txt; } vrKeyboard keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_D) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { ShowFPS = !ShowFPS; guiText.enabled = ShowFPS; } if (keyb != null && (keyb.IsKeyToggled(MiddleVR.VRK_W) || keyb.IsKeyToggled(MiddleVR.VRK_Z)) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { ShowWand = !ShowWand; ShowWandGeometry(ShowWand); } // Toggle Fly mode on interactions if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_F) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { vrInteractionManager interMan = vrInteractionManager.GetInstance(); uint interactionNb = interMan.GetInteractionsNb(); for (uint i = 0; i < interactionNb; ++i) { vrProperty flyProp = interMan.GetInteractionByIndex(i).GetProperty("Fly"); if (flyProp != null) { flyProp.SetBool(!flyProp.GetBool()); } } } // Navigation mode switch if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_N) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { // Disable current nav MonoBehaviour currentNavigation = (MonoBehaviour)m_Wand.GetComponent((string)m_NavigationScipts[m_CurrentNavigationNb]); if (currentNavigation != null) { currentNavigation.enabled = false; } // Enable next nav m_CurrentNavigationNb = (m_CurrentNavigationNb + 1) % m_NavigationScipts.Count; currentNavigation = (MonoBehaviour)m_Wand.GetComponent((string)m_NavigationScipts[m_CurrentNavigationNb]); if (currentNavigation != null) { currentNavigation.enabled = true; } } DeltaTime = kernel.GetDeltaTime(); MiddleVRTools.Log(4, "[<] Unity Update - End"); } else { //Debug.LogWarning("[ ] If you have an error mentionning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."); } // If QualityLevel changed, we have to reset the Unity Manager if (m_NeedDelayedRenderingReset) { if (m_RenderingResetDelay == 0) { MiddleVRTools.Log(3, "[ ] Graphic quality forced, reset Unity Manager."); MiddleVRTools.VRReset(); MiddleVRTools.CreateViewportsAndCameras(DontChangeWindowGeometry, m_AllowRenderTargetAA); m_isGeometrySet = false; m_NeedDelayedRenderingReset = false; } else { --m_RenderingResetDelay; } } }