protected void Start() { MVRTools.Log(4, "[>] VR Manager Start."); m_Kernel.DeleteLateObjects(); // 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)) { var activeViewport0 = m_DisplayMgr.GetActiveViewport(0); var stereoMode = (VRStereoMode)activeViewport0.GetStereoMode(); bool useOpenGLQuadbuffer = activeViewport0.GetStereo() && stereoMode == VRStereoMode.VRStereoMode_QuadBuffer; 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 vrValue FramerateCheckboxHandler(vrValue iValue) { m_VRManager.ShowFPS = iValue.GetBool(); MVRTools.Log("[ ] Show Frame Rate: " + iValue.GetBool().ToString()); return null; }
private vrValue FlyCheckboxHandler(vrValue iValue) { m_VRManager.Fly = iValue.GetBool(); MVRTools.Log("[ ] Fly mode: " + iValue.GetBool().ToString()); return null; }
protected virtual void OnDeactivate() { MVRTools.Log(3, "[ ] VRInteraction: Deactivating '" + m_Interaction.GetName() + "'."); }
private vrValue ResetZeroButtonHandler(vrValue iValue) { MVRTools.Log("[ ] Reload level zero."); Application.LoadLevel(0); return null; }
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 var listener = new vrEventListener(EventListener); MiddleVR.VRInteractionMgr.AddEventListener(listener); MVRTools.RegisterObject(this, listener); // Register commands MVRTools.RegisterCommands(this); VRWebView webViewScript = GetComponent <VRWebView>(); if (webViewScript == null) { MVRTools.Log(1, "[X] VRMenu does not have a WebView."); return; } m_GUIRendererWeb = new vrGUIRendererWeb("", webViewScript.webView); MVRTools.RegisterObject(this, m_GUIRendererWeb); m_Menu = new vrWidgetMenu("VRMenu.VRManagerMenu", m_GUIRendererWeb); MVRTools.RegisterObject(this, m_Menu); // Navigation m_NavigationOptions = new vrWidgetMenu("VRMenu.NavigationOptions", m_Menu, "Navigation"); MVRTools.RegisterObject(this, m_NavigationOptions); 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"); var navigationSeparator = new vrWidgetSeparator("VRMenu.NavigationSeparator", m_NavigationOptions); MVRTools.RegisterObject(this, navigationSeparator); var flyCheckbox = new vrWidgetToggleButton("VRMenu.FlyCheckbox", m_NavigationOptions, "Fly", MVRTools.GetCommand("FlyCheckboxHandler"), m_VRManager.Fly); MVRTools.RegisterObject(this, flyCheckbox); var collisionsCheckbox = new vrWidgetToggleButton("VRMenu.CollisionsCheckbox", m_NavigationOptions, "Navigation Collisions", MVRTools.GetCommand("CollisionsCheckboxHandler"), m_VRManager.NavigationCollisions); MVRTools.RegisterObject(this, collisionsCheckbox); // Manipulation m_ManipulationOptions = new vrWidgetMenu("VRMenu.ManipulationOptions", m_Menu, "Manipulation"); MVRTools.RegisterObject(this, m_ManipulationOptions); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationRay"), "Ray", m_ManipulationOptions, "ManipulationRayHandler"); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationHomer"), "Homer", m_ManipulationOptions, "ManipulationHomerHandler"); var manipulationSeparator = new vrWidgetSeparator("VRMenu.ManipulationSeparator", m_ManipulationOptions); MVRTools.RegisterObject(this, manipulationSeparator); var returnObjectsCheckbox = new vrWidgetToggleButton("VRMenu.ReturnObjectsCheckbox", m_ManipulationOptions, "Return Objects", MVRTools.GetCommand("ReturnObjectsCheckboxHandler"), m_VRManager.ManipulationReturnObjects); MVRTools.RegisterObject(this, returnObjectsCheckbox); // Virtual Hand m_VirtualHandOptions = new vrWidgetMenu("VRMenu.VirtualHandOptions", m_Menu, "Virtual Hand"); MVRTools.RegisterObject(this, m_VirtualHandOptions); CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionVirtualHandGogo"), "Gogo", m_VirtualHandOptions, "VirtualHandGogoButtonHandler"); // General var generalSeparator = new vrWidgetSeparator("VRMenu.GeneralSeparator", m_Menu); MVRTools.RegisterObject(this, generalSeparator); var generalOptions = new vrWidgetMenu("VRMenu.GeneralOptions", m_Menu, "General Options"); MVRTools.RegisterObject(this, generalOptions); var framerateCheckbox = new vrWidgetToggleButton("VRMenu.FramerateCheckbox", generalOptions, "Show Frame Rate", MVRTools.GetCommand("FramerateCheckboxHandler"), m_VRManager.ShowFPS); MVRTools.RegisterObject(this, framerateCheckbox); var proxiWarningCheckbox = new vrWidgetToggleButton("VRMenu.ProxiWarningCheckbox", generalOptions, "Show Proximity Warning", MVRTools.GetCommand("ProxiWarningCheckboxHandler"), m_VRManager.ShowScreenProximityWarnings); MVRTools.RegisterObject(this, proxiWarningCheckbox); // Reset and Exit var resetButtonMenu = new vrWidgetMenu("VRMenu.ResetButtonMenu", m_Menu, "Reset Simulation"); MVRTools.RegisterObject(this, resetButtonMenu); var resetCurrentButton = new vrWidgetButton("VRMenu.ResetCurrentButton", resetButtonMenu, "Reload current level", MVRTools.GetCommand("ResetCurrentButtonHandler")); MVRTools.RegisterObject(this, resetCurrentButton); var resetZeroButton = new vrWidgetButton("VRMenu.ResetZeroButton", resetButtonMenu, "Reload level zero", MVRTools.GetCommand("ResetZeroButtonHandler")); MVRTools.RegisterObject(this, resetZeroButton); var exitButtonMenu = new vrWidgetMenu("VRMenu.ExitButtonMenu", m_Menu, "Exit Simulation"); MVRTools.RegisterObject(this, exitButtonMenu); var exitButton = new vrWidgetButton("VRMenu.ExitButton", exitButtonMenu, "Yes, Exit Simulation", MVRTools.GetCommand("ExitButtonHandler")); MVRTools.RegisterObject(this, exitButton); }
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); }
// Update is called once per frame void Update() { leftScreenOutput.transform.localRotation = MVRTools.ToUnity(leftScreenParent.GetOrientationLocal()); rightScreenOutput.transform.localRotation = MVRTools.ToUnity(rightScreenParent.GetOrientationLocal()); }
private vrPhysicsGeometry CreateGeometry(bool iAreChildGeometriesMerged) { string geometryName = m_PhysicsBodyName + ".Geometry"; MiddleVRTools.Log(4, "[>] PhysicsBody: Creation of the physics geometry '" + geometryName + "'."); var rootMatrixWorld = transform.localToWorldMatrix; vrPhysicsGeometry ret = new vrPhysicsGeometry(geometryName); uint geometryIndex = 0; var queue = new Queue <GameObject>(); queue.Enqueue(gameObject); while (queue.Count > 0) { var go = queue.Dequeue(); Mesh mesh = null; var meshCollider = go.GetComponent <MeshCollider>(); if (meshCollider != null && meshCollider.enabled) { mesh = meshCollider.sharedMesh; if (mesh != null) { MiddleVRTools.Log(2, "[ ] PhysicsBody: the GO '" + go.name + "' will furnish a physics geometry for '" + geometryName + "' from its MeshCollider."); } } // No mesh from collider was found so let's try from the mesh filter. if (mesh == null) { var meshFilter = go.GetComponent <MeshFilter>(); if (meshFilter != null) { mesh = meshFilter.sharedMesh; if (mesh != null) { MiddleVRTools.Log(2, "[ ] PhysicsBody: the GO '" + go.name + "' will furnish a physics geometry for '" + geometryName + "' from its MeshFilter."); } } } if (mesh != null) { // The top geometry keep its name, others will get the word "sub". if (geometryIndex != 0) { ret.SetSubGeometryName(geometryIndex, geometryName + ".sub." + go.name); } ConvertGeometry(rootMatrixWorld, go.transform, mesh, ret, geometryIndex); ++geometryIndex; MiddleVRTools.Log(4, "[ ] PhysicsBody: Physics geometry created from GO '" + go.name + "'."); } if (iAreChildGeometriesMerged) { foreach (Transform child in go.transform) { if (child.gameObject.activeSelf) { queue.Enqueue(child.gameObject); } } } } var scaleShearMatrix = MVRTools.ComputeScaleShearMatrixWorld(transform); ret.TransformStoredVertices(MVRTools.FromUnity(scaleShearMatrix)); MiddleVRTools.Log(4, "[<] PhysicsBody: Creation of the physics geometry '" + geometryName + "' ended."); return(ret); }
// Private methods private void InitializeVR() { mouseButtons[0] = mouseButtons[1] = mouseButtons[2] = false; if (m_displayLog) { var guiGO = new GameObject(); #pragma warning disable 618 m_GUI = guiGO.AddComponent <GUIText>(); #pragma warning restore 618 guiGO.transform.localPosition = new UnityEngine.Vector3(0.5f, 0.0f, 0.0f); m_GUI.pixelOffset = new UnityEngine.Vector2(15.0f, 0.0f); m_GUI.anchor = TextAnchor.LowerCenter; } if (MiddleVR.VRKernel != null) { MVRTools.Log(3, "[ ] VRKernel already alive, reset Unity Manager."); MVRTools.VRReset(); m_isInit = true; // Not needed because this is the first execution of this script instance // m_isGeometrySet = false; m_FirstFrameAfterReset = MiddleVR.VRKernel.GetFrame(); } else { if (CustomLicense) { MVRTools.CustomLicense = true; MVRTools.CustomLicenseName = CustomLicenseName; MVRTools.CustomLicenseCode = CustomLicenseCode; } m_isInit = MVRTools.VRInitialize(ConfigFile); } if (SimpleClusterParticles) { _SetParticlesSeeds(); } // Get AA from vrx configuration file m_AntiAliasingLevel = (int)MiddleVR.VRDisplayMgr.GetAntiAliasing(); DumpOptions(); if (!m_isInit) { var guiGO = new GameObject(); #pragma warning disable 618 m_GUI = guiGO.AddComponent <GUIText>(); #pragma warning restore 618 guiGO.transform.localPosition = new UnityEngine.Vector3(0.2f, 0.0f, 0.0f); m_GUI.pixelOffset = new UnityEngine.Vector2(0.0f, 0.0f); m_GUI.anchor = TextAnchor.LowerLeft; string txt = m_Kernel.GetLogString(true); print(txt); m_GUI.text = txt; return; } m_Kernel = MiddleVR.VRKernel; m_DeviceMgr = MiddleVR.VRDeviceMgr; m_DisplayMgr = MiddleVR.VRDisplayMgr; m_ClusterMgr = MiddleVR.VRClusterMgr; if (SimpleCluster) { SetupSimpleCluster(); } if (DisableExistingCameras) { Camera[] cameras = GameObject.FindObjectsOfType(typeof(Camera)) as Camera[]; foreach (Camera cam in cameras) { if (cam.targetTexture == null) { cam.enabled = false; } } } MVRNodesCreator.Instance.CreateNodes( VRSystemCenterNode, DebugNodes, DebugScreens, GrabExistingNodes, TemplateCamera); MVRTools.CreateViewportsAndCameras(DontChangeWindowGeometry, true); MVRTools.Log(4, "[<] End of VR initialization script"); }
// Update is called once per frame protected void Update() { // Initialize interactions if (!m_InteractionsInitialized) { _SetNavigation(Navigation); _SetManipulation(Manipulation); _SetVirtualHandMapping(VirtualHandMapping); m_InteractionsInitialized = true; } MVRNodesMapper nodesMapper = MVRNodesMapper.Instance; nodesMapper.UpdateNodesUnityToMiddleVR(); if (m_isInit) { MVRTools.Log(4, "[>] Unity Update - Start"); if (m_Kernel.GetFrame() >= m_FirstFrameAfterReset + 1 && !m_isGeometrySet && !Application.isEditor) { if (!DontChangeWindowGeometry) { m_DisplayMgr.SetUnityWindowGeometry(); } m_isGeometrySet = true; } // Set the random seed in kernel for dispatching only during start-up. if (m_Kernel.GetFrame() == 0) { // Disable obsolescence warning for Random.seed as we only use it to initalize // the MiddleVR random seed. // Using Random.seed was deprecated because it is a single integer and does not // contain the full state of the random number generator and thus could not be // used for restoring or synchronizing the state. #pragma warning disable 618 // The cast is safe because the seed is always positive. m_Kernel._SetRandomSeed((uint)UnityEngine.Random.seed); #pragma warning restore 618 // With clustering, a client will be set by a call to kernel.Update(). if (m_ClusterMgr.IsCluster()) { if (m_shareRandomStateCommand == null) { m_shareRandomStateCommand = new vrCommand("MVR_ShareRandomState", (vrValue val) => { UnityEngine.Random.state = JsonUtility.FromJson <UnityEngine.Random.State>(val.GetString()); return(new vrValue()); }); } if (m_ClusterMgr.IsServer()) { m_shareRandomStateCommand.Do(new vrValue(JsonUtility.ToJson(UnityEngine.Random.state))); } } } m_Kernel.Update(); UpdateInput(); if (ShowFPS) { #pragma warning disable 618 this.GetComponent <GUIText>().text = m_Kernel.GetFPS().ToString("f2"); #pragma warning restore 618 } nodesMapper.UpdateNodesMiddleVRToUnity(false); MVRTools.UpdateCameraProperties(m_Kernel, m_DisplayMgr, nodesMapper); if (m_displayLog) { string txt = m_Kernel.GetLogString(true); print(txt); m_GUI.text = txt; } vrKeyboard keyb = m_DeviceMgr.GetKeyboard(); if (keyb != null) { if (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT)) { if (keyb.IsKeyToggled(MiddleVR.VRK_D)) { ShowFPS = !ShowFPS; } if (keyb.IsKeyToggled(MiddleVR.VRK_W) || keyb.IsKeyToggled(MiddleVR.VRK_Z)) { ShowWand = !ShowWand; ShowWandGeometry(ShowWand); } // Toggle Fly mode on interactions if (keyb.IsKeyToggled(MiddleVR.VRK_F)) { Fly = !Fly; } // Navigation mode switch if (keyb.IsKeyToggled(MiddleVR.VRK_N)) { vrInteraction navigation = _GetNextInteraction("ContinuousNavigation"); if (navigation != null) { MiddleVR.VRInteractionMgr.Activate(navigation); } } } } DeltaTime = m_Kernel.GetDeltaTime(); MVRTools.Log(4, "[<] Unity Update - End"); } else { //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."); } }
// Public methods public void Log(string text) { MVRTools.Log(text); }
// Update is called once per frame void Update() { //MVRTools.Log("VRManagerUpdate"); // Initialize interactions if (!m_InteractionsInitialized) { _SetNavigation(Navigation); _SetManipulation(Manipulation); _SetVirtualHandMapping(VirtualHandMapping); m_InteractionsInitialized = true; } MVRNodesMapper nodesMapper = MVRNodesMapper.Instance; nodesMapper.UpdateNodesUnityToMiddleVR(); if (m_isInit) { MVRTools.Log(4, "[>] Unity Update - Start"); if (m_Kernel.GetFrame() >= m_FirstFrameAfterReset + 1 && !m_isGeometrySet && !Application.isEditor) { if (!DontChangeWindowGeometry) { m_DisplayMgr.SetUnityWindowGeometry(); } m_isGeometrySet = true; } if (m_Kernel.GetFrame() == 0) { // Set the random seed in kernel for dispatching only during start-up. // With clustering, a client will be set by a call to kernel.Update(). if (!m_ClusterMgr.IsCluster() || (m_ClusterMgr.IsCluster() && m_ClusterMgr.IsServer())) { // The cast is safe because the seed is always positive. uint seed = (uint)UnityEngine.Random.seed; m_Kernel._SetRandomSeed(seed); } } m_Kernel.Update(); if (m_Kernel.GetFrame() == 0) { // Set the random seed in a client only during start-up. if (m_ClusterMgr.IsCluster() && m_ClusterMgr.IsClient()) { // The cast is safe because the seed comes from // a previous value of Unity. int seed = (int)m_Kernel.GetRandomSeed(); UnityEngine.Random.seed = seed; } } UpdateInput(); if (ShowFPS) { this.GetComponent <GUIText>().text = m_Kernel.GetFPS().ToString("f2"); } nodesMapper.UpdateNodesMiddleVRToUnity(false); MVRTools.UpdateCameraProperties(); if (m_displayLog) { string txt = m_Kernel.GetLogString(true); print(txt); m_GUI.text = txt; } vrKeyboard keyb = m_DeviceMgr.GetKeyboard(); if (keyb != null) { if (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT)) { if (keyb.IsKeyToggled(MiddleVR.VRK_D)) { ShowFPS = !ShowFPS; } if (keyb.IsKeyToggled(MiddleVR.VRK_W) || keyb.IsKeyToggled(MiddleVR.VRK_Z)) { ShowWand = !ShowWand; ShowWandGeometry(ShowWand); } // Toggle Fly mode on interactions if (keyb.IsKeyToggled(MiddleVR.VRK_F)) { Fly = !Fly; } // Navigation mode switch if (keyb.IsKeyToggled(MiddleVR.VRK_N)) { vrInteraction navigation = _GetNextInteraction("ContinuousNavigation"); if (navigation != null) { MiddleVR.VRInteractionMgr.Activate(navigation); } } } } DeltaTime = m_Kernel.GetDeltaTime(); MVRTools.Log(4, "[<] Unity Update - End"); } else { //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."); } // If QualityLevel changed, we have to reset the Unity Manager if (m_NeedDelayedRenderingReset) { if (m_RenderingResetDelay == 0) { MVRTools.Log(3, "[ ] Graphic quality forced, reset Unity Manager."); MVRTools.VRReset(); MVRTools.CreateViewportsAndCameras(DontChangeWindowGeometry, m_AllowRenderTargetAA); m_isGeometrySet = false; m_NeedDelayedRenderingReset = false; } else { --m_RenderingResetDelay; } } }
protected void Start() { MVRTools.Log("[X] Using deprecated script VRApplySharedTransform"); }
private void CollisionsCheckboxHandler(bool iValue) { m_VRManager.NavigationCollisions = iValue; MVRTools.Log("[ ] Navigation Collisions: " + iValue); }
private vrValue ReturnObjectsCheckboxHandler(vrValue iValue) { m_VRManager.ManipulationReturnObjects = iValue.GetBool(); MVRTools.Log("[ ] Manipulation return objects: " + iValue.GetBool().ToString()); return(null); }
private void ReturnObjectsCheckboxHandler(bool iValue) { m_VRManager.ManipulationReturnObjects = iValue; MVRTools.Log("[ ] Manipulation return objects: " + iValue); }
protected void Update() { if (!m_Attached) { GameObject node = GameObject.Find(VRParentNode); if (VRParentNode.Length == 0) { MVRTools.Log(0, "[X] AttachToNode: Please specify a valid VRParentNode name."); } if (node != null) { Vector3 oldPos = transform.localPosition; Quaternion oldRot = transform.localRotation; Vector3 oldScale = transform.localScale; // Setting new parent transform.parent = node.transform; if (!KeepLocalPosition) { transform.localPosition = new Vector3(0, 0, 0); } else { transform.localPosition = oldPos; } if (!KeepLocalRotation) { transform.localRotation = new Quaternion(0, 0, 0, 1); } else { transform.localRotation = oldRot; } if (!KeepLocalScale) { transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); } else { transform.localScale = oldScale; } MVRTools.Log(2, "[+] AttachToNode: " + this.name + " attached to : " + node.name); m_Attached = true; // Stop this component now. enabled = false; } else { if (m_Searched == false) { MVRTools.Log(0, "[X] AttachToNode: Failed to find Game object '" + VRParentNode + "'"); m_Searched = true; // Stop this component now. enabled = false; } } } }
public void CreateInteractionToggleButton(vrInteraction iInteraction, string iButtonName, vrWidgetMenu iParentMenu, string iButtonHandlerName) { string itName = iInteraction.GetName(); vrWidgetToggleButton button = new vrWidgetToggleButton("VRMenu." + itName + "ToggleButton", iParentMenu, iButtonName, MVRTools.GetCommand(iButtonHandlerName), iInteraction.IsActive()); m_Buttons.Add(itName, button); MVRTools.RegisterObject(this, button); }
private void ResetZeroButtonHandler() { MVRTools.Log("[ ] Reload level zero."); SceneManager.LoadScene(0); }
protected bool AddConstraint() { vrPhysicsEngine physicsEngine = MiddleVR.VRPhysicsMgr.GetPhysicsEngine(); if (physicsEngine == null) { return(false); } if (m_PhysicsConstraint == null) { return(false); } bool addedToSimulation = false; // Cannot fail since we require this component. VRPhysicsBody body0 = GetComponent <VRPhysicsBody>(); VRPhysicsBody body1 = null; if (m_ConnectedBody != null) { body1 = m_ConnectedBody.GetComponent <VRPhysicsBody>(); } if (body0.PhysicsBody != null) { var scaleShearMatrix = MVRTools.ComputeScaleShearMatrixWorld(transform); m_PhysicsConstraint.SetPosition(MiddleVRTools.FromUnity(scaleShearMatrix * Anchor)); m_PhysicsConstraint.SetAxis(MiddleVRTools.FromUnity(Axis)); m_PhysicsConstraint.SetAngularLowerLimit(m_AngularLimits.Min); m_PhysicsConstraint.SetAngularUpperLimit(m_AngularLimits.Max); m_PhysicsConstraint.SetAngularReferencePosition(m_AngularZeroPosition); m_PhysicsConstraint.SetLinearLowerLimit(m_LinearLimits.Min); m_PhysicsConstraint.SetLinearUpperLimit(m_LinearLimits.Max); m_PhysicsConstraint.SetLinearReferencePosition(m_LinearZeroPosition); m_PhysicsConstraint.SetBody(0, body0.PhysicsBody); m_PhysicsConstraint.SetBody(1, body1 != null ? body1.PhysicsBody : null); addedToSimulation = physicsEngine.AddConstraint(m_PhysicsConstraint); if (addedToSimulation) { MiddleVRTools.Log(3, "[ ] The constraint '" + m_PhysicsConstraintName + "' was added to the physics simulation."); } else { MiddleVRTools.Log(0, "[X] Failed to add the constraint '" + m_PhysicsConstraintName + "' to the physics simulation."); } } else { MiddleVRTools.Log(0, "[X] The PhysicsBody of '" + name + "' for the cylindrical physics constraint '" + m_PhysicsConstraintName + "' is null."); } return(addedToSimulation); }
private void ExitButtonHandler() { MVRTools.Log("[ ] Exit simulation."); m_VRManager.QuitApplication(); }
// General private vrValue ResetCurrentButtonHandler(vrValue iValue) { MVRTools.Log("[ ] Reload current level."); Application.LoadLevel(Application.loadedLevel); return null; }
private void FramerateCheckboxHandler(bool iValue) { m_VRManager.ShowFPS = iValue; MVRTools.Log("[ ] Show Frame Rate: " + iValue); }
private vrValue ExitButtonHandler(vrValue iValue) { MVRTools.Log("[ ] Exit simulation."); m_VRManager.QuitApplication(); return null; }
private void ProxiWarningCheckboxHandler(bool iValue) { m_VRManager.ShowScreenProximityWarnings = iValue; MVRTools.Log("[ ] Show proximity warnings: " + iValue); }
private vrValue ProxiWarningCheckboxHandler(vrValue iValue) { m_VRManager.ShowScreenProximityWarnings = iValue.GetBool(); MVRTools.Log("[ ] Show proximity warnings: " + iValue.GetBool().ToString()); return null; }
private void FlyCheckboxHandler(bool iValue) { m_VRManager.Fly = iValue; MVRTools.Log("[ ] Fly mode: " + iValue); }
private vrValue CollisionsCheckboxHandler(vrValue iValue) { m_VRManager.NavigationCollisions = iValue.GetBool(); MVRTools.Log("[ ] Navigation Collisions: " + iValue.GetBool().ToString()); return null; }
private void Start() { // Automatically register all methods with the [VRCommand] attribute MVRTools.RegisterCommands(this); // Create GUI VRWebView webViewScript = GetComponent <VRWebView>(); if (webViewScript == null) { MVRTools.Log(0, "[X] VRGUIMenuSample does not have a WebView."); enabled = false; return; } var GUIRendererWeb = new vrGUIRendererWeb("", webViewScript.webView); // Register the object so the garbage collector does not collect it after this method. // The object will be disposed when the GameObject is destroyed. MVRTools.RegisterObject(this, GUIRendererWeb); var menu = new vrWidgetMenu("GUIMenuSample.MainMenu", GUIRendererWeb); MVRTools.RegisterObject(this, menu); var button1 = new vrWidgetButton("GUIMenuSample.Button1", menu, "Button", MVRTools.GetCommand("ButtonHandler")); MVRTools.RegisterObject(this, button1); var separator = new vrWidgetSeparator("GUIMenuSample.Separator1", menu); MVRTools.RegisterObject(this, separator); m_Checkbox = new vrWidgetToggleButton("GUIMenuSample.Checkbox", menu, "Toggle Button", MVRTools.GetCommand("CheckboxHandler"), true); MVRTools.RegisterObject(this, m_Checkbox); var submenu = new vrWidgetMenu("GUIMenuSample.SubMenu", menu, "Sub Menu"); submenu.SetVisible(true); MVRTools.RegisterObject(this, submenu); var radio1 = new vrWidgetRadioButton("GUIMenuSample.Radio1", submenu, "Huey", MVRTools.GetCommand("RadioHandler"), "Huey"); MVRTools.RegisterObject(this, radio1); var radio2 = new vrWidgetRadioButton("GUIMenuSample.Radio2", submenu, "Dewey", MVRTools.GetCommand("RadioHandler"), "Dewey"); MVRTools.RegisterObject(this, radio2); var radio3 = new vrWidgetRadioButton("GUIMenuSample.Radio3", submenu, "Louie", MVRTools.GetCommand("RadioHandler"), "Louie"); MVRTools.RegisterObject(this, radio3); var picker = new vrWidgetColorPicker("GUIMenuSample.ColorPicker", menu, "Color Picker", MVRTools.GetCommand("ColorPickerHandler"), new vrVec4(0, 0, 0, 0)); MVRTools.RegisterObject(this, picker); var slider = new vrWidgetSlider("GUIMenuSample.Slider", menu, "Slider", MVRTools.GetCommand("SliderHandler"), 50.0f, 0.0f, 100.0f, 1.0f); MVRTools.RegisterObject(this, slider); vrValue listContents = vrValue.CreateList(); listContents.AddListItem("Item 1"); listContents.AddListItem("Item 2"); var list = new vrWidgetList("GUIMenuSample.List", menu, "List", MVRTools.GetCommand("ListHandler"), listContents, 0); MVRTools.RegisterObject(this, list); }