private static void CleanAssets() { // Ensure this is called only once EditorApplication.update -= CleanAssets; if (!File.Exists(Path.Combine(Application.dataPath, "MiddleVR_Source_Project.txt"))) { // Clean old deprecated assets from previous MiddleVR versions string[] assetsToDelete = { "Assets/Editor/VRCustomEditor.cs", "Assets/MiddleVR/Resources/OVRLensCorrectionMat.mat", "Assets/MiddleVR/Scripts/Internal/VRCameraCB.cs", "Assets/MiddleVR/Assets/Materials/WandRayMaterial.mat", "Assets/Plugins/MiddleVR_UnityRendering.dll", "Assets/Plugins/MiddleVR_UnityRendering_x64.dll" }; int filesDeleted = 0; foreach (string assetToDelete in assetsToDelete) { if (AssetDatabase.DeleteAsset(assetToDelete)) { filesDeleted++; MVRTools.Log(3, "[ ] Deleting deprecated MiddleVR asset '" + assetToDelete + "'."); } } if (filesDeleted > 0) { MVRTools.Log(3, "[ ] Deleted " + filesDeleted.ToString() + " deprecated MiddleVR asset(s)."); AssetDatabase.Refresh(); } } }
private void _SetManipulation(EManipulation iManpulation) { Manipulation = iManpulation; VRInteractionManipulationRay manipulationRay = m_Wand.GetComponent <VRInteractionManipulationRay>(); VRInteractionManipulationHomer manipulationHomer = m_Wand.GetComponent <VRInteractionManipulationHomer>(); if (manipulationRay == null || manipulationHomer == null) { MVRTools.Log(2, "[~] Some manipulation scripts are missing on the Wand."); return; } switch (Manipulation) { case EManipulation.None: MiddleVR.VRInteractionMgr.Deactivate(manipulationRay.GetInteraction()); MiddleVR.VRInteractionMgr.Deactivate(manipulationHomer.GetInteraction()); break; case EManipulation.Ray: MiddleVR.VRInteractionMgr.Activate(manipulationRay.GetInteraction()); break; case EManipulation.Homer: MiddleVR.VRInteractionMgr.Activate(manipulationHomer.GetInteraction()); break; default: break; } }
public void QuitApplication() { MVRTools.Log(3, "[ ] Execute QuitCommand."); // Call cluster command so that all cluster nodes quit m_QuitCommand.Do(new vrValue()); }
public override void OnInspectorGUI() { GUILayout.BeginVertical(); if (GUILayout.Button("Pick html file")) { string path = EditorUtility.OpenFilePanel("Please choose a HTML file", "", "html"); if (path.Length != 0) { // Don't use Path.DirectorySeparatorChar because // Unity always returns paths with slashes string basePath = Application.dataPath + "/"; if (path.StartsWith(basePath)) { path = path.Substring(basePath.Length); } MVRTools.Log("[+] Picked " + path); m_VRWebViewScript.URL = path; EditorUtility.SetDirty(m_VRWebViewScript); } } DrawDefaultInspector(); GUILayout.EndVertical(); }
public void QuitApplication() { MVRTools.Log(3, "[ ] Execute QuitCommand."); // Call cluster command so that all cluster nodes quit MiddleVR.VRKernel.ExecuteCommand("VRManager.QuitApplicationCommand"); }
private void ResetCurrentButtonHandler() { MVRTools.Log("[ ] Reload current level."); Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name); }
public void ApplyVRSettings() { PlayerSettings.defaultIsFullScreen = false; PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled; PlayerSettings.runInBackground = true; PlayerSettings.captureSingleScreen = false; PlayerSettings.MTRendering = false; //PlayerSettings.usePlayerLog = false; //PlayerSettings.useDirect3D11 = false; MVRTools.Log("VR Player settings changed:"); MVRTools.Log("- DefaultIsFullScreen = false"); MVRTools.Log("- DisplayResolutionDialog = Disabled"); MVRTools.Log("- RunInBackground = true"); MVRTools.Log("- CaptureSingleScreen = false"); //MVRTools.Log("- UsePlayerLog = false"); string[] names = QualitySettings.names; int qualityLevel = QualitySettings.GetQualityLevel(); // Disable VSync on all quality levels for (int i = 0; i < names.Length; ++i) { QualitySettings.SetQualityLevel(i); QualitySettings.vSyncCount = 0; } QualitySettings.SetQualityLevel(qualityLevel); MVRTools.Log("Quality settings changed for all quality levels:"); MVRTools.Log("- VSyncCount = 0"); }
private void _SetVirtualHandMapping(EVirtualHandMapping iVirtualHandMapping) { VirtualHandMapping = iVirtualHandMapping; VRInteractionVirtualHandGogo virtualHandGogo = m_Wand.GetComponent <VRInteractionVirtualHandGogo>(); if (virtualHandGogo == null) { MVRTools.Log(2, "[~] The virtual hand Gogo script is missing on the Wand."); return; } switch (VirtualHandMapping) { case EVirtualHandMapping.Direct: MiddleVR.VRInteractionMgr.Deactivate(virtualHandGogo.GetInteraction()); break; case EVirtualHandMapping.Gogo: MiddleVR.VRInteractionMgr.Activate(virtualHandGogo.GetInteraction()); break; default: break; } }
private void Start() { MVRTools.Log(4, "[ ] Unity: StartCoroutine PostFrameUpdate"); ContinuePostFrameUpdate = true; StartCoroutine(PostFrameUpdate()); }
protected void Start() { MVRTools.Log(4, "[>] VR Manager Start."); m_Kernel.DeleteLateObjects(); #if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 m_AllowRenderTargetAA = true; #endif // Reset Manager's position so text display is correct. transform.position = new UnityEngine.Vector3(0, 0, 0); transform.rotation = new Quaternion(); transform.localScale = new UnityEngine.Vector3(1, 1, 1); m_Wand = GameObject.Find("VRWand"); m_VRMenu = GameObject.Find("VRMenu"); ShowWandGeometry(ShowWand); _EnableProximityWarning(m_ShowScreenProximityWarnings); _EnableFPSDisplay(m_ShowFPS); _EnableNavigationFly(m_Fly); _EnableNavigationCollision(m_NavigationCollisions); _EnableManipulationReturnObjects(m_ManipulationReturnObjects); _EnableVRMenu(m_UseVRMenu); if (ForceQuality) { QualitySettings.SetQualityLevel(ForceQualityIndex); } // Manage VSync after the quality settings MVRTools.ManageVSync(); // Set AA from vrx configuration file QualitySettings.antiAliasing = m_AntiAliasingLevel; // Check if MiddleVR Reset is needed if (!Application.isEditor && (ForceQuality || QualitySettings.antiAliasing > 1)) { bool useOpenGLQuadbuffer = m_DisplayMgr.GetActiveViewport(0).GetStereo() && (m_DisplayMgr.GetActiveViewport(0).GetStereoMode() == 0); //VRStereoMode_QuadBuffer = 0 if (useOpenGLQuadbuffer || m_ClusterMgr.GetForceOpenGLConversion()) { m_NeedDelayedRenderingReset = true; m_RenderingResetDelay = 1; } } m_QuitCommand = new vrCommand("VRManager.QuitApplicationCommand", _QuitApplicationCommandHandler); MVRTools.Log(4, "[<] End of VR Manager Start."); }
private void Update() { MVRTools.Log(4, "[>] Unity: VR EndFrame Update!"); MiddleVR.VRKernel.EndFrameUpdate(); MVRTools.Log(4, "[<] Unity: End of VR EndFrame Update!"); }
void AddClusterScripts(GameObject iObject) { MVRTools.Log(2, "[ ] Adding cluster sharing scripts to " + iObject.name); if (iObject.GetComponent <VRShareTransform>() == null) { iObject.AddComponent <VRShareTransform>(); } }
private void _QuitApplicationCommandHandler() { MVRTools.Log(3, "[ ] Received QuitApplicationCommand"); MVRTools.Log("[ ] Unity says we're quitting."); MiddleVR.VRKernel.SetQuitting(); Application.Quit(); }
// This coroutine when started, will wait for every end of frame and then // call the PostFrameUpdate of the vrKernel. private IEnumerator PostFrameUpdate() { while (ContinuePostFrameUpdate) { yield return(new WaitForEndOfFrame()); var 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."); #pragma warning disable 618 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."; #pragma warning restore 618 } MVRTools.Log(4, "[>] Unity: Start of VR PostFrameUpdate."); if (kernel == null || deviceMgr == null || clusterMgr == null) { InitManagers(); } if (deviceMgr != null) { var keyboard = deviceMgr.GetKeyboard(); if (keyboard != null) { // Because when the voice chat is on the input are not redirected to MiddleVR we need to check the Input.GetKey(KeyCode.Escape) if (mgr != null && mgr.QuitOnEsc && (keyboard.IsKeyPressed((uint)MiddleVR.VRK_ESCAPE) || Input.GetKey(KeyCode.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."); } } }
public void SelectRelativePathForConfigFile() { string path = EditorUtility.OpenFilePanel("Please choose MiddleVR configuration file", Application.dataPath + "/MiddleVRConfigFile", "vrx"); string fileName = path.Split('/').Last(); MVRTools.Log("[+] Picked " + fileName); mgr.ConfigFile = fileName; EditorUtility.SetDirty(mgr); }
private vrValue _QuitApplicationCommandHandler(vrValue iValue) { MVRTools.Log(3, "[ ] Received QuitApplicationCommand"); MVRTools.Log("[ ] Unity says we're quitting."); MiddleVR.VRKernel.SetQuitting(); Application.Quit(); return(null); }
private void Update() { MVRTools.Log(4, "[>] Unity: VR EndFrame Update!"); MiddleVR.VRKernel.EndFrameUpdate(); MVRTools.Log(4, "[ ] Unity: StartCoRoutine PostFrameUpdate"); StartCoroutine(PostFrameUpdate()); MVRTools.Log(4, "[<] Unity: End of VR EndFrame Update!"); }
void Update() { MVRTools.Log(4, "[>] Unity: VR PostFrame Update!"); MiddleVR.VRClusterMgr.EndFrameUpdate(); MVRTools.Log(4, "[ ] Unity: StartCoRoutine EndOfFrame!"); StartCoroutine(EndOfFrame()); MVRTools.Log(4, "[<] Unity: End of VR PostFrame Update!"); }
protected void Start() { m_SelectionMgr = this.GetComponent <VRSelectionManager>(); if (m_SelectionMgr == null) { MVRTools.Log(1, "[X] VRWand: impossible to retrieve VRSelectionManager."); } _FindWandGeometry(); SetRayLength(DefaultRayLength); }
private void Start() { // Create commands m_ButtonCommand = new vrCommand("GUIMenuSample.ButtonCommand", ButtonHandler); m_CheckboxCommand = new vrCommand("GUIMenuSample.CheckboxCommand", CheckboxHandler); m_RadioCommand = new vrCommand("GUIMenuSample.RadioCommand", RadioHandler); m_ColorPickerCommand = new vrCommand("GUIMenuSample.ColorPickerCommand", ColorPickerHandler); m_SliderCommand = new vrCommand("GUIMenuSample.SliderCommand", SliderHandler); m_ListCommand = new vrCommand("GUIMenuSample.ListCommand", ListHandler); // Create GUI m_GUIRendererWeb = null; VRWebView webViewScript = GetComponent <VRWebView>(); if (webViewScript == null) { MVRTools.Log(0, "[X] VRGUIMenuSample does not have a WebView."); enabled = false; return; } m_GUIRendererWeb = new vrGUIRendererWeb("", webViewScript.webView); m_Menu = new vrWidgetMenu("GUIMenuSample.MainMenu", m_GUIRendererWeb); m_Button1 = new vrWidgetButton("GUIMenuSample.Button1", m_Menu, "Button", m_ButtonCommand); new vrWidgetSeparator("GUIMenuSample.Separator1", m_Menu); m_Checkbox = new vrWidgetToggleButton("GUIMenuSample.Checkbox", m_Menu, "Toggle Button", m_CheckboxCommand, true); m_Submenu = new vrWidgetMenu("GUIMenuSample.SubMenu", m_Menu, "Sub Menu"); m_Submenu.SetVisible(true); m_Radio1 = new vrWidgetRadioButton("GUIMenuSample.Radio1", m_Submenu, "Huey", m_RadioCommand, "Huey"); m_Radio2 = new vrWidgetRadioButton("GUIMenuSample.Radio2", m_Submenu, "Dewey", m_RadioCommand, "Dewey"); m_Radio3 = new vrWidgetRadioButton("GUIMenuSample.Radio3", m_Submenu, "Louie", m_RadioCommand, "Louie"); m_Picker = new vrWidgetColorPicker("GUIMenuSample.ColorPicker", m_Menu, "Color Picker", m_ColorPickerCommand, new vrVec4(0, 0, 0, 0)); m_Slider = new vrWidgetSlider("GUIMenuSample.Slider", m_Menu, "Slider", m_SliderCommand, 50.0f, 0.0f, 100.0f, 1.0f); vrValue listContents = vrValue.CreateList(); listContents.AddListItem("Item 1"); listContents.AddListItem("Item 2"); m_List = new vrWidgetList("GUIMenuSample.List", m_Menu, "List", m_ListCommand, listContents, 0); }
// Use this public method from interaction scripts to initialize and start collision public void Initialize() { if (m_CollisionNode != null && m_NavigationNode != null && m_VRNavigationNode != null) { m_LastCollisionNodePosition = m_CollisionNode.transform.position; m_Initialized = true; MVRTools.Log(2, "[ ] VRHeadCollision: initialized"); } else { MVRTools.Log(2, "[X] VRHeadCollision: impossible to retrieve specified navigation or collision nodes."); } }
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 TestDevices() { vrTracker tracker = null; vrJoystick joy = null; vrAxis axis = null; vrButtons buttons = null; var deviceMgr = MiddleVR.VRDeviceMgr; // Getting a reference to different device types if (deviceMgr != null) { tracker = deviceMgr.GetTracker("VRPNTracker0.Tracker0"); joy = deviceMgr.GetJoystickByIndex(0); axis = deviceMgr.GetAxis("VRPNAxis0.Axis"); buttons = deviceMgr.GetButtons("VRPNButtons0.Buttons"); } // Getting tracker data if (tracker != null) { MVRTools.Log("TrackerX : " + tracker.GetPosition().x()); } // Testing joystick button if (joy != null && joy.IsButtonPressed(0)) { MVRTools.Log("Joystick!"); } // Testing axis value if (axis != null && axis.GetValue(0) > 0) { MVRTools.Log("Axis Value: " + axis.GetValue(0)); } // Testing button state if (buttons != null) { if (buttons.IsToggled(0)) { MVRTools.Log("Button 0 pressed !"); } if (buttons.IsToggled(0, false)) { MVRTools.Log("Button 0 released !"); } } }
public override void OnInspectorGUI() { GUILayout.BeginVertical(); if (GUILayout.Button("Pick html file")) { string path = EditorUtility.OpenFilePanel("Please choose a HTML file", "", "html"); MVRTools.Log("[+] Picked " + path); m_VRWebViewScript.m_URL = path; EditorUtility.SetDirty(m_VRWebViewScript); } DrawDefaultInspector(); GUILayout.EndVertical(); }
void Update() { if (IsActive()) { if (!m_Initialized) { if (GameObject.Find("VRManager").GetComponent <VRManagerScript>().VRSystemCenterNode != null) { m_VRSystemCenterNode = GameObject.Find("VRManager").GetComponent <VRManagerScript>().VRSystemCenterNode.transform; } else { vrNode3D vrSystemMVRNode = MiddleVR.VRDisplayMgr.GetNodeByTag(MiddleVR.VR_SYSTEM_CENTER_NODE_TAG); if (vrSystemMVRNode != null) { m_VRSystemCenterNode = GameObject.Find(vrSystemMVRNode.GetName()).transform; } } m_Initialized = true; } if (ElasticRepresentationPrefab == null) { MVRTools.Log("[X] VRInteractionNavigationElastic error: bad elastic prefab reference"); return; } if (m_it.HasNavigationStarted()) { m_ElasticRepresentationObject = (GameObject)GameObject.Instantiate(ElasticRepresentationPrefab); m_ElasticRepresentationObject.transform.parent = m_VRSystemCenterNode; m_ElasticRepresentation = m_ElasticRepresentationObject.GetComponent <VRElasticRepresentation>(); UpdateElasticRepresentation(); } else if (m_it.IsNavigationRunning()) { UpdateElasticRepresentation(); } else if (m_it.IsNavigationStopped() && m_ElasticRepresentation != null) { GameObject.Destroy(m_ElasticRepresentationObject); } } }
public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { // If this is not a MiddleVR package import, skip bool importingMvrDll = false; foreach (string s in importedAssets) { // MiddleVR_Unity3D.dll should be imported only at package import if (s.Contains("MiddleVR_Unity3D.dll")) { importingMvrDll = true; break; } } if (!importingMvrDll) { return; } MVRTools.Log(3, "[>] Begin package import post-process..."); if (!File.Exists(Path.Combine(Application.dataPath, "MiddleVR_Source_Project.txt"))) { // Clean old deprecated files from previous MiddleVR versions string[] filesToDelete = { Path.Combine("Editor", "VRCustomEditor.cs"), Path.Combine("Resources", "OVRLensCorrectionMat.mat"), Path.Combine(Path.Combine(Path.Combine("MiddleVR", "Scripts"), "Internal"), "VRCameraCB.cs"), Path.Combine(Path.Combine(Path.Combine("MiddleVR", "Assets"), "Materials"), "WandRayMaterial.mat"), Path.Combine("Plugins", "MiddleVR_UnityRendering.dll"), Path.Combine("Plugins", "MiddleVR_UnityRendering_x64.dll") }; foreach (string fileToDelete in filesToDelete) { string filePath = Path.Combine(Application.dataPath, fileToDelete); if (File.Exists(filePath)) { MVRTools.Log(3, "[ ] Package import post process: clean deprecated MiddleVR files. Deleting file '" + filePath + "'."); File.Delete(filePath); } } } MVRTools.Log(3, "[<] End package import post-process."); }
private void ManipulationHomerHandler(bool iValue) { // Activate Homer Manipulation vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationHomer"); bool activate = iValue; if (activate) { MiddleVR.VRInteractionMgr.Activate(interaction); MVRTools.Log("[ ] Manipulation Homer activated."); } else { MiddleVR.VRInteractionMgr.Deactivate(interaction); MVRTools.Log("[ ] Manipulation Homer deactivated."); } }
private void VirtualHandGogoButtonHandler(bool iValue) { // Activate Gogo Virtual Hand vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionVirtualHandGogo"); bool activate = iValue; if (activate) { MiddleVR.VRInteractionMgr.Activate(interaction); MVRTools.Log("[ ] Virtual Hand Gogo activated."); } else { MiddleVR.VRInteractionMgr.Deactivate(interaction); MVRTools.Log("[ ] Virtual Hand Gogo deactivated."); } }
private VRNetworkInteractionsHandler GetNetworkInteractionsHandler() { if (!m_HasSearchedForNetworkInteractionsHandler) { m_NetworkInteractionsHandler = FindObjectsOfType <VRNetworkInteractionsHandler>() .FirstOrDefault(handlerComponent => handlerComponent.isLocalPlayer); if (m_NetworkInteractionsHandler == null) { MVRTools.Log(1, "[X] VRInteraction: Cannot find an instance of VRNetworkInteractionsHandler on a local player."); } m_HasSearchedForNetworkInteractionsHandler = true; } return(m_NetworkInteractionsHandler); }
protected virtual void Start() { if (!m_SyncDirIsSet) { _SetSyncDirection(m_SyncDirection); } if (gameObject.GetComponent <Collider>() == null) { gameObject.AddComponent <BoxCollider>(); } if (gameObject.GetComponent <Collider>() == null) { MVRTools.Log("[X] Actor object '" + gameObject.name + "' has no collider!! Put one or it won't act. "); } }