Enabling/disabling VR with SteamVR v.2
See original GitHub issueHi everybody!
As the title says, I’m trying to enable/disable VR between different applications, and I need to do it as many times as I want. I’m working with Unity 2017.4 and SteamVR 2.0.1 (I also tried with 2.2, same behaviour).
There is a simple solution for this:
IEnumerator SwitchOutOfVr() {
XRSettings.LoadDeviceByName(""); // Empty string loads the "None" device.
// Wait one frame!
yield return null;
XRSettings.enabled = false;
}
but I got nasty exceptions since Actions and Poses don’t seem to be handled correctly after disabling VR; instead, the update functions are still called:
NullReferenceException: Object reference not set to an instance of an object Valve.VR.SteamVR_Action_Pose_Source.UpdateValue (Boolean skipStateAndEventUpdates) (at Assets/SteamVR/Input/SteamVR_Action_Pose.cs:571) Valve.VR.SteamVR_Action_Skeleton_Source.UpdateValue (Boolean skipStateAndEventUpdates) (at Assets/SteamVR/Input/SteamVR_Action_Skeleton.cs:904) Valve.VR.SteamVR_Action_Skeleton.UpdateValue (Boolean skipStateAndEventUpdates) (at Assets/SteamVR/Input/SteamVR_Action_Skeleton.cs:65) Valve.VR.SteamVR_Input.UpdateSkeletonActions (Boolean skipSendingEvents) (at Assets/SteamVR/Input/SteamVR_Input.cs:355) Valve.VR.SteamVR_Input.LateUpdate () (at Assets/SteamVR/Input/SteamVR_Input.cs:269) Valve.VR.SteamVR_Behaviour.LateUpdate () (at Assets/SteamVR/Scripts/SteamVR_Behaviour.cs:219)
I’d like to know if I’m doing something wrong or it’s something that will be fixed. Thanks in advance for any hint.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:11

Top Related StackOverflow Question
Yeah, being able to disable steamvr seems like a reasonable request. I’ll add it to the feature request list.
Hello, I have exactly the same problem, I need enabling/disabling VR as many times as the player wants, however in the second time I get the same errors and in the application build I lose the controllers tracking. I’m working with the player prefab, I have the current plugin version 2.5.0 (sdk 1.8.19) and SteamVR 1.8.20 version.
I’ll be very glad with any help 😃
This is my code:
This are the errors: