private void Start() { // Make sure the base interaction is started InitializeBaseInteraction(); m_VRMgr = GameObject.Find("VRManager").GetComponent <VRManagerScript>(); m_it = new vrInteractionManipulationHomer(Name); // Must tell base class about our interaction SetInteraction(m_it); MiddleVR.VRInteractionMgr.AddInteraction(m_it); MiddleVR.VRInteractionMgr.Activate(m_it); m_HandNode = MiddleVR.VRDisplayMgr.GetNode(HandNode); if (m_HandNode != null) { m_it.SetGrabWandButton(WandGrabButton); m_it.SetTranslationScale(TranslationScale); m_it.SetRotationScale(RotationScale); m_it.SetManipulatorNode(m_HandNode); } else { MiddleVR.VRLog(2, "[X] VRInteractionManipulationHomer: One or several nodes are missing."); } m_Wand = this.GetComponent <VRWand>(); }
private void Start() { // Make sure the base interaction is started InitializeBaseInteraction(); m_VRMgr = GameObject.Find("VRManager").GetComponent<VRManagerScript>(); m_it = new vrInteractionManipulationHomer(Name); // Must tell base class about our interaction SetInteraction(m_it); MiddleVR.VRInteractionMgr.AddInteraction(m_it); MiddleVR.VRInteractionMgr.Activate(m_it); m_HandNode = MiddleVR.VRDisplayMgr.GetNode( HandNode ); if ( m_HandNode != null ) { m_it.SetGrabWandButton( WandGrabButton ); m_it.SetTranslationScale( TranslationScale ); m_it.SetRotationScale( RotationScale ); m_it.SetManipulatorNode(m_HandNode); } else { MiddleVR.VRLog( 2, "[X] VRInteractionManipulationHomer: One or several nodes are missing." ); } m_Wand = this.GetComponent<VRWand>(); }
void Awake() { mgr = (VRManagerScript)target; if (!m_SettingsApplied) { ApplyVRSettings(); m_SettingsApplied = true; } }
void Awake() { mgr = (VRManagerScript)target; if( !m_SettingsApplied ) { ApplyVRSettings(); m_SettingsApplied = true; } }
private IEnumerator PostFrameUpdate() { yield return(new WaitForEndOfFrame()); VRManagerScript mgr = GetComponent <VRManagerScript>(); if (mgr != null && MiddleVR.VRKernel == null) { Debug.LogWarning("[ ] If you have an error mentioning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."); mgr.GetComponent <GUIText>().text = "[ ] Check the console window to check if you have an error mentioning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."; } MVRTools.Log(4, "[>] Unity: Start of VR PostFrameUpdate."); if (kernel == null || deviceMgr == null || clusterMgr == null) { InitManagers(); } if (deviceMgr != null) { vrKeyboard keyboard = deviceMgr.GetKeyboard(); if (keyboard != null) { if (mgr != null && mgr.QuitOnEsc && keyboard.IsKeyPressed((uint)MiddleVR.VRK_ESCAPE)) { mgr.QuitApplication(); } } else { if (!LoggedNoKeyboard) { MVRTools.Log("[X] No VR keyboard."); LoggedNoKeyboard = true; } } } if (kernel != null) { kernel.PostFrameUpdate(); } MVRTools.Log(4, "[<] Unity: End of VR PostFrameUpdate."); if (kernel != null && kernel.GetFrame() == 2 && !Application.isEditor) { MVRTools.Log(2, "[ ] If the application is stuck here and you're using Quad-buffer active stereoscopy, make sure that in the Player Settings of Unity, the option 'Run in Background' is checked."); } }
void Awake() { vrManager = FindObjectOfType<VRManagerScript>(); if (vrManager.TemplateCamera != null) { AudioListener audioListener = vrManager.TemplateCamera.GetComponent<AudioListener>(); if (audioListener != null) { audioListener.enabled = false; Debug.Log("[MVRTools] Disabeling AudioListener component on template camera : " + vrManager.TemplateCamera.name, this); } } if (DisableAllAudioListeners) { foreach (AudioListener audioListener in FindObjectsOfType<AudioListener>()) { if (audioListener != null) { audioListener.enabled = false; Debug.Log("[MVRTools] Disabeling AudioListener component on game object : " + audioListener.name, this); } } } }
// Update is called once per frame void Update() { GameObject directionRefNode = null; GameObject nodeToMove = null; GameObject turnNode = null; directionRefNode = GameObject.Find(DirectionReferenceNode); nodeToMove = GameObject.Find(NodeToMove); turnNode = GameObject.Find(TurnAroundNode); if (m_SearchedRefNode == false && directionRefNode == null) { MiddleVRTools.Log("[X] VRWandNavigation: Couldn't find '" + DirectionReferenceNode + "'"); m_SearchedRefNode = true; } if (m_SearchedNodeToMove == false && nodeToMove == null) { MiddleVRTools.Log("[X] VRWandNavigation: Couldn't find '" + NodeToMove + "'"); m_SearchedNodeToMove = true; } if (m_SearchedRotationNode == false && TurnAroundNode.Length > 0 && turnNode == null) { MiddleVRTools.Log("[X] VRWandNavigation: Couldn't find '" + TurnAroundNode + "'"); m_SearchedRotationNode = true; } if (directionRefNode != null && nodeToMove != null) { float speed = 0.0f; float speedR = 0.0f; GameObject vrmgr = GameObject.Find("VRManager"); if (vrmgr != null) { VRManagerScript script = vrmgr.GetComponent <VRManagerScript>(); if (script != null) { /// FORWARD float forward = script.WandAxisVertical; //MiddleVRTools.Log("Forward: " + forward); float deltaTime = (float)MiddleVR.VRKernel.GetDeltaTime(); if (Math.Abs(forward) > 0.1) { speed = forward * NavigationSpeed * deltaTime; } /// ROTATION float rotation = script.WandAxisHorizontal; if (Math.Abs(rotation) > 0.1) { speedR = rotation * RotationSpeed * deltaTime; } /// Computing direction Vector3 translationVector = new Vector3(0, 0, 1); Vector3 tVec = translationVector; Vector3 nVec = new Vector3(tVec.x * speed, tVec.y * speed, tVec.z * speed); Vector3 mVec = directionRefNode.transform.TransformDirection(nVec); if (Fly == false) { mVec.y = 0.0f; } nodeToMove.transform.Translate(mVec, Space.World); if (turnNode != null) { nodeToMove.transform.RotateAround(turnNode.transform.position, new Vector3(0, 1, 0), speedR); } else { nodeToMove.transform.Rotate(new Vector3(0, 1, 0), speedR); } } } } }
protected void Start() { // Retrieve the VRManager VRManagerScript[] foundVRManager = FindObjectsOfType(typeof(VRManagerScript)) as VRManagerScript[]; if (foundVRManager.Length != 0) { m_VRManager = foundVRManager[0]; } else { MVRTools.Log("[X] VRMenu: impossible to retrieve the VRManager."); return; } // Start listening to MiddleVR events m_Listener = new vrEventListener(EventListener); MiddleVR.VRInteractionMgr.AddEventListener(m_Listener); // Create commands // General m_ResetCurrentButtonCommand = new vrCommand("VRMenu.ResetCurrentButtonCommand", ResetCurrentButtonHandler); m_ResetZeroButtonCommand = new vrCommand("VRMenu.ResetZeroButtonCommand", ResetZeroButtonHandler); m_ExitButtonCommand = new vrCommand("VRMenu.ExitButtonCommand", ExitButtonHandler); m_FramerateCheckboxCommand = new vrCommand("VRMenu.FramerateCheckboxCommand", FramerateCheckboxHandler); m_ProxiWarningCheckboxCommand = new vrCommand("VRMenu.ProxiWarningCheckboxCommand", ProxiWarningCheckboxHandler); // Navigation m_FlyCheckboxCommand = new vrCommand("VRMenu.FlyCheckboxCommand", FlyCheckboxHandler); m_CollisionsCheckboxCommand = new vrCommand("VRMenu.CollisionsCheckboxCommand", CollisionsCheckboxHandler); // Manipulation m_ReturnObjectsCheckboxCommand = new vrCommand("VRMenu.ReturnObjectsCheckboxCommand", ReturnObjectsCheckboxHandler); // Create GUI m_GUIRendererWeb = null; VRWebView webViewScript = GetComponent <VRWebView>(); if (webViewScript == null) { MVRTools.Log(1, "[X] VRMenu does not have a WebView."); return; } m_GUIRendererWeb = new vrGUIRendererWeb("", webViewScript.webView); m_Menu = new vrWidgetMenu("VRMenu.VRManagerMenu", m_GUIRendererWeb); // Navigation m_NavigationOptions = new vrWidgetMenu("VRMenu.NavigationOptions", m_Menu, "Navigation"); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationWandJoystick"), "Joystick", m_NavigationOptions, NavigationJoystickHandler); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationElastic"), "Elastic", m_NavigationOptions, NavigationElasticHandler); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationGrabWorld"), "Grab The World", m_NavigationOptions, NavigationGrabWorldHandler); m_NavigationSeparator = new vrWidgetSeparator("VRMenu.NavigationSeparator", m_NavigationOptions); m_FlyCheckbox = new vrWidgetToggleButton("VRMenu.FlyCheckbox", m_NavigationOptions, "Fly", m_FlyCheckboxCommand, m_VRManager.Fly); m_CollisionsCheckbox = new vrWidgetToggleButton("VRMenu.CollisionsCheckbox", m_NavigationOptions, "Navigation Collisions", m_CollisionsCheckboxCommand, m_VRManager.NavigationCollisions); // Manipulation m_ManipulationOptions = new vrWidgetMenu("VRMenu.ManipulationOptions", m_Menu, "Manipulation"); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationRay"), "Ray", m_ManipulationOptions, ManipulationRayHandler); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationHomer"), "Homer", m_ManipulationOptions, ManipulationHomerHandler); m_ManipulationSeparator = new vrWidgetSeparator("VRMenu.ManipulationSeparator", m_ManipulationOptions); m_ReturnObjectsCheckbox = new vrWidgetToggleButton("VRMenu.ReturnObjectsCheckbox", m_ManipulationOptions, "Return Objects", m_ReturnObjectsCheckboxCommand, m_VRManager.ManipulationReturnObjects); // Virtual Hand m_VirtualHandOptions = new vrWidgetMenu("VRMenu.VirtualHandOptions", m_Menu, "Virtual Hand"); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionVirtualHandGogo"), "Gogo", m_VirtualHandOptions, VirtualHandGogoButtonHandler); // General m_GeneralSeparator = new vrWidgetSeparator("VRMenu.GeneralSeparator", m_Menu); m_GeneralOptions = new vrWidgetMenu("VRMenu.GeneralOptions", m_Menu, "General Options"); m_FramerateCheckbox = new vrWidgetToggleButton("VRMenu.FramerateCheckbox", m_GeneralOptions, "Show Frame Rate", m_FramerateCheckboxCommand, m_VRManager.ShowFPS); m_ProxiWarningCheckbox = new vrWidgetToggleButton("VRMenu.ProxiWarningCheckbox", m_GeneralOptions, "Show Proximity Warning", m_ProxiWarningCheckboxCommand, m_VRManager.ShowScreenProximityWarnings); // Reset and Exit m_ResetButtonMenu = new vrWidgetMenu("VRMenu.ResetButtonMenu", m_Menu, "Reset Simulation"); m_ResetCurrentButton = new vrWidgetButton("VRMenu.ResetCurrentButton", m_ResetButtonMenu, "Reload current level", m_ResetCurrentButtonCommand); m_ResetZeroButton = new vrWidgetButton("VRMenu.ResetZeroButton", m_ResetButtonMenu, "Reload level zero", m_ResetZeroButtonCommand); m_ExitButtonMenu = new vrWidgetMenu("VRMenu.ExitButtonMenu", m_Menu, "Exit Simulation"); m_ExitButton = new vrWidgetButton("VRMenu.ExitButton", m_ExitButtonMenu, "Yes, Exit Simulation", m_ExitButtonCommand); }
protected void Start() { // Retrieve the VRManager VRManagerScript[] foundVRManager = FindObjectsOfType(typeof(VRManagerScript)) as VRManagerScript[]; if (foundVRManager.Length != 0) { m_VRManager = foundVRManager[0]; } else { MVRTools.Log("[X] VRMenu: impossible to retrieve the VRManager."); return; } // Start listening to MiddleVR events m_Listener = new vrEventListener(EventListener); MiddleVR.VRInteractionMgr.AddEventListener(m_Listener); // Create commands // General m_ResetCurrentButtonCommand = new vrCommand("VRMenu.ResetCurrentButtonCommand", ResetCurrentButtonHandler); m_ResetZeroButtonCommand = new vrCommand("VRMenu.ResetZeroButtonCommand", ResetZeroButtonHandler); m_ExitButtonCommand = new vrCommand("VRMenu.ExitButtonCommand", ExitButtonHandler); m_FramerateCheckboxCommand = new vrCommand("VRMenu.FramerateCheckboxCommand", FramerateCheckboxHandler); m_ProxiWarningCheckboxCommand = new vrCommand("VRMenu.ProxiWarningCheckboxCommand", ProxiWarningCheckboxHandler); // Navigation m_FlyCheckboxCommand = new vrCommand("VRMenu.FlyCheckboxCommand", FlyCheckboxHandler); m_CollisionsCheckboxCommand = new vrCommand("VRMenu.CollisionsCheckboxCommand", CollisionsCheckboxHandler); // Manipulation m_ReturnObjectsCheckboxCommand = new vrCommand("VRMenu.ReturnObjectsCheckboxCommand", ReturnObjectsCheckboxHandler); // Create GUI m_GUIRendererWeb = null; VRWebView webViewScript = GetComponent<VRWebView>(); if (webViewScript == null) { MVRTools.Log(1, "[X] VRMenu does not have a WebView."); return; } m_GUIRendererWeb = new vrGUIRendererWeb("", webViewScript.webView); m_Menu = new vrWidgetMenu("VRMenu.VRManagerMenu", m_GUIRendererWeb); // Navigation m_NavigationOptions = new vrWidgetMenu("VRMenu.NavigationOptions", m_Menu, "Navigation"); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationWandJoystick"), "Joystick", m_NavigationOptions, NavigationJoystickHandler); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationElastic"), "Elastic", m_NavigationOptions, NavigationElasticHandler); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationGrabWorld"), "Grab The World", m_NavigationOptions, NavigationGrabWorldHandler); m_NavigationSeparator = new vrWidgetSeparator("VRMenu.NavigationSeparator", m_NavigationOptions); m_FlyCheckbox = new vrWidgetToggleButton("VRMenu.FlyCheckbox", m_NavigationOptions, "Fly", m_FlyCheckboxCommand, m_VRManager.Fly); m_CollisionsCheckbox = new vrWidgetToggleButton("VRMenu.CollisionsCheckbox", m_NavigationOptions, "Navigation Collisions", m_CollisionsCheckboxCommand, m_VRManager.NavigationCollisions); // Manipulation m_ManipulationOptions = new vrWidgetMenu("VRMenu.ManipulationOptions", m_Menu, "Manipulation"); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationRay"), "Ray", m_ManipulationOptions, ManipulationRayHandler); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationHomer"), "Homer", m_ManipulationOptions, ManipulationHomerHandler); m_ManipulationSeparator = new vrWidgetSeparator("VRMenu.ManipulationSeparator", m_ManipulationOptions); m_ReturnObjectsCheckbox = new vrWidgetToggleButton("VRMenu.ReturnObjectsCheckbox", m_ManipulationOptions, "Return Objects", m_ReturnObjectsCheckboxCommand, m_VRManager.ManipulationReturnObjects); // Virtual Hand m_VirtualHandOptions = new vrWidgetMenu("VRMenu.VirtualHandOptions", m_Menu, "Virtual Hand"); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionVirtualHandGogo"), "Gogo", m_VirtualHandOptions, VirtualHandGogoButtonHandler); // General m_GeneralSeparator = new vrWidgetSeparator("VRMenu.GeneralSeparator", m_Menu); m_GeneralOptions = new vrWidgetMenu("VRMenu.GeneralOptions", m_Menu, "General Options"); m_FramerateCheckbox = new vrWidgetToggleButton("VRMenu.FramerateCheckbox", m_GeneralOptions, "Show Frame Rate", m_FramerateCheckboxCommand, m_VRManager.ShowFPS); m_ProxiWarningCheckbox = new vrWidgetToggleButton("VRMenu.ProxiWarningCheckbox", m_GeneralOptions, "Show Proximity Warning", m_ProxiWarningCheckboxCommand, m_VRManager.ShowScreenProximityWarnings); // Reset and Exit m_ResetButtonMenu = new vrWidgetMenu("VRMenu.ResetButtonMenu", m_Menu, "Reset Simulation"); m_ResetCurrentButton = new vrWidgetButton("VRMenu.ResetCurrentButton", m_ResetButtonMenu, "Reload current level", m_ResetCurrentButtonCommand); m_ResetZeroButton = new vrWidgetButton("VRMenu.ResetZeroButton", m_ResetButtonMenu, "Reload level zero", m_ResetZeroButtonCommand); m_ExitButtonMenu = new vrWidgetMenu("VRMenu.ExitButtonMenu", m_Menu, "Exit Simulation"); m_ExitButton = new vrWidgetButton("VRMenu.ExitButton", m_ExitButtonMenu, "Yes, Exit Simulation", m_ExitButtonCommand); }
void Start() { gameManager = GameObject.Find("GameManager").GetComponent <Modelisation.GameManager>(); menuManager = GameObject.Find("Utilisateur").GetComponent <MenuManager>(); // Retrieve the VRManager VRManagerScript[] foundVRManager = FindObjectsOfType(typeof(VRManagerScript)) as VRManagerScript[]; if (foundVRManager.Length != 0) { m_VRManager = foundVRManager[0]; } else { MVRTools.Log("[X] VRMenu: impossible to retrieve the VRManager."); return; } // Start listening to MiddleVR events m_Listener = new vrEventListener(EventListener); MiddleVR.VRKernel.AddEventListener(m_Listener); // Create commands // General m_ResetButtonCommand = new vrCommand("VRMenu.ResetButtonCommand", ResetButtonHandler); m_ExitButtonCommand = new vrCommand("VRMenu.ExitButtonCommand", ExitButtonHandler); // Mode modeAssisteCommand = new vrCommand("VRMenu.modeAssisteCommand", ModeAssisteHandler); modeLibreCommand = new vrCommand("VRMenu.modeLibreCommand", ModeLibreHandler); // Scenario scenarioAppelCommand = new vrCommand("VRMenu.ScenarioAppelCommand", ScenarioAppelHandler); scenarioInfirmierCommand = new vrCommand("VRMenu.ScenarioInfirmierCommand", ScenarioInfirmierHandler); scenarioInconnuCommand = new vrCommand("VRMenu.ScenarioInconnuCommand", ScenarioInconnuHandler); // Create GUI m_GUIRendererWeb = null; VRWebView webViewScript = GetComponent <VRWebView>(); if (webViewScript == null) { MVRTools.Log(1, "[X] VRMenu does not have a WebView."); return; } m_GUIRendererWeb = new vrGUIRendererWeb("", webViewScript.webView); m_Menu = new vrWidgetMenu("VRMenu.VRManagerMenu", m_GUIRendererWeb); // Mode menuChoixMode = new vrWidgetMenu("VRMenu.ChoixMode", m_Menu, "Modes"); modeAssiste = new vrWidgetButton("VRMenu.ModeAssisteButton", menuChoixMode, "Passer en mode assisté", modeAssisteCommand); modeLibre = new vrWidgetButton("VRMenu.ModeLibreButton", menuChoixMode, "Passer en mode libre", modeLibreCommand); // Scénario menuChoixScenar = new vrWidgetMenu("VRMenu.ChoixScenario", m_Menu, "Scenarios"); scenarAppel = new vrWidgetButton("VRMenu.ScenarAppelButton", menuChoixScenar, "Appel téléphonique", scenarioAppelCommand); scenarInfirmier = new vrWidgetButton("VRMenu.ScenarInfirmierButton", menuChoixScenar, "Infirmier à l'entrée", scenarioInfirmierCommand); scenarInconnu = new vrWidgetButton("VRMenu.ScenarInconnuButton", menuChoixScenar, "Inconnu à l'entrée", scenarioInconnuCommand); // Reset and Exit m_ResetButton = new vrWidgetButton("VRMenu.ResetCurrentButton", m_Menu, "Reload simulation", m_ResetButtonCommand); m_ExitButton = new vrWidgetButton("VRMenu.ExitButton", m_Menu, "Exit simulation", m_ExitButtonCommand); }
IEnumerator EndOfFrame() { yield return(new WaitForEndOfFrame()); VRManagerScript mgr = GetComponent <VRManagerScript>(); if (mgr != null && MiddleVR.VRKernel == null) { 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."); mgr.guiText.text = "[ ] Check the console window to check 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."; } MiddleVRTools.Log(4, "[>] VR End of Frame."); if (kernel == null) { kernel = MiddleVR.VRKernel; } if (dmgr == null) { dmgr = MiddleVR.VRDeviceMgr; } if (dmgr != null) { vrKeyboard keyb = dmgr.GetKeyboard(); if (keyb != null) { VRManagerScript vrmgr = GetComponent <VRManagerScript>(); if (vrmgr != null && vrmgr.QuitOnEsc && keyb.IsKeyPressed((uint)MiddleVR.VRK_ESCAPE)) { if (Application.isEditor) { MiddleVRTools.Log("[ ] If we were in player mode, MiddleVR would exit."); } else { MiddleVRTools.Log("[ ] Unity says we're quitting."); MiddleVR.VRKernel.SetQuitting(); Application.Quit(); } } } else { if (!LoggedNoKeyboard) { MiddleVRTools.Log("[X] No VR keyboard"); LoggedNoKeyboard = true; } } } if (kernel != null) { /* * MiddleVRTools.Log("SavingRT"); ; * SaveRT(); */ kernel.PostFrameUpdate(); } MiddleVRTools.Log(4, "[<] End of VR End of Frame."); if (kernel != null && kernel.GetFrame() == 2 && !Application.isEditor) { MiddleVRTools.Log(2, "[ ] If the application is stuck here and you're using Quad-buffer active stereoscopy, make sure that in the Player Settings of Unity, the option 'Run in Background' is checked."); } }