Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. The 2023.1 beta is now available for testing. To find out what's new, have a look at our 2023.1 feature highlights.
    Dismiss Notice

VR OpenVR How to prevent openvr from initializing automatically

Discussion in '5.4 Beta' started by BGog, May 18, 2016.

  1. BGog

    BGog

    Joined:
    Feb 10, 2014
    Posts:
    10
    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?
     
    zhou_unity likes this.
  2. robinb-u3d

    robinb-u3d

    Unity Technologies

    Joined:
    Jul 13, 2015
    Posts:
    18
    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
     
    Jason-RT-Bond likes this.
  3. BGog

    BGog

    Joined:
    Feb 10, 2014
    Posts:
    10
    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.
     
  4. robinb-u3d

    robinb-u3d

    Unity Technologies

    Joined:
    Jul 13, 2015
    Posts:
    18
    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
     
  5. skarphace

    skarphace

    Joined:
    Jun 11, 2016
    Posts:
    1
    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
    Code (csharp):
    1. VRSettings.LoadDeviceByName("OpenVR")
    , I get the following message:

    Code (csharp):
    1. OpenVR initialization failed.  Ensure 'Virtual Reality Supported' is checked in Player Settings, and OpenVR is added to the list of Virtual Reality SDKs.
    2. UnityEngine.Debug:Log(Object)
    3. SteamVR:CreateInstance() (at Assets/SteamVR/Scripts/SteamVR.cs:75)
    4. SteamVR:get_instance() (at Assets/SteamVR/Scripts/SteamVR.cs:44)
    5. SteamVR_Camera:OnEnable() (at Assets/SteamVR/Scripts/SteamVR_Camera.cs:100)
    I've also tried adding the following at the same time as LoadDeviceByName

    Code (csharp):
    1. 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?