OpenVR How to prevent openvr from initializing automatically

My project is a VR multiplayer game. In 5.3 I was able to easily work on the networking on a single computer by having either the editor or the built game initialize openvr and the other would just run on the monitor. However as of 5.4 beta openvr initializes automatically and kills either the playing editor or the standalone because only one app can use openvr at a time.

How can I set it so openvr does not initialize when the game starts?

1 Like

Hi

I believe you should be able to add “None” as a VR device to the list of VR SDK’s supported in the PlayerSettings section of the editor where you have Open VR set (using the + button at the bottom of the SDK list). If you then drag “None” to be the first SDK in the list this should cause Unity to start up in no VR mode and you can then go into VR mode by calling VRSettings.LoadDeviceByName().

Hope this helps.

Robin

1 Like

Thank you for the reply. I tried this and it does’t work.

I removed “OpenVR” from the list and added “None” to the list. This does prevent the loading of OpenVR.
Then I call: VRSettings.LoadDeviceByName(“OpenVR”);

This shows the messages showing that it initialized properly. However when I enable my steamvr camerarig, unity crashes.

Hi

You want both “None” to be first in the list and then “Open VR” to be second in the list rather than not there. This will cause Unity to add support for Open VR but to use None first. This should hopefully so it crashing for you.

Cheers

Robin

3 Likes

I’ve tried this method but haven’t gotten anywhere. Using 5.4.0f2 with fully up to date steamvr plugin. Once I instantiate my player prefab(with steamvr camera attacked), after VRSettings.LoadDeviceByName("OpenVR"), I get the following message:

OpenVR initialization failed.  Ensure 'Virtual Reality Supported' is checked in Player Settings, and OpenVR is added to the list of Virtual Reality SDKs.
UnityEngine.Debug:Log(Object)
SteamVR:CreateInstance() (at Assets/SteamVR/Scripts/SteamVR.cs:75)
SteamVR:get_instance() (at Assets/SteamVR/Scripts/SteamVR.cs:44)
SteamVR_Camera:OnEnable() (at Assets/SteamVR/Scripts/SteamVR_Camera.cs:100)

I’ve also tried adding the following at the same time as LoadDeviceByName

OpenVR.Init(ref VRerror, EVRApplicationType.VRApplication_Scene);

But no change. Could you share a little bit more on how you were able to initialize OpenVR in a non-headless state with this configuration?