Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

OpenVR/None: "HmdNotFound" error without HMD

Discussion in 'VR' started by SimRuJ, Jan 23, 2019.

  1. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    My app uses VR SDKs (Project Settings - Player) in this order:
    - Open VR
    - None

    If I unplug the headset (Lenovo Explorer) and start the app, Unity (2017.3.1f1) prints an error message:
    Isn't the "None" SDK supposed to become active if there's no headset connected, so you can use your app with or without an HMD? I'm not trying to get tracking to work without the HMD, I just want to use it as a normal, non-VR desktop app too (so without Steam/SteamVR/OpenVR).

    How do I make this work? Do I really have to export/give two different versions to the users, one with "Virtual Reality Supported" (Project Settings - Player) ticked, one without it ticked?
     
    Last edited: Jan 23, 2019
    glenneroo likes this.
  2. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    I've now tested it this way:

    Flip the SDK, so "None" is first in the list and "OpenVR" second, then use the following code to decide what to use:
    Code (CSharp):
    1. if(XRDevice.isPresent) {
    2.     XRSettings.LoadDeviceByName("OpenVR");
    3. } else {
    4.     XRSettings.LoadDeviceByName("None");
    5. }
    Starting the app without an HMD doesn't produce the error message anymore but now there's a new problem:

    While plugging the headset in opens the "Mixed Reality-Portal", it doesn't open SteamVR and if SteamVR isn't open, Unity apparently also doesn't recognize the headset as a VR device. This also means that "XRDevice.isPresent" always returns "false" (same thing with "XRSettings.isDeviceActive") and "XRSettings.loadedDeviceName" of course returns an empty string.
    Btw, switching the SDKs, so "OpenVR" is first, starting my app to open SteamVR and then switching back doesn't work - Unity instantly forgets about the headset again.

    Has anyone got any idea/suggestion what I could try to automatically detect an HMD, while still being able to run the app in non-VR mode (without the "Hmd Not Found (108)" message)?

    Edit: Even if I force it with "if(!XRDevice.isPresent)" and additionally add "XRSettings.enabled = true", it doesn't work. SteamVR starts but the headset only shows the dark gray waiting room. As soon as I move "OpenVR" back to the top of the list, everything's back to normal in VR mode but then I keep getting the "Hmd not found" error message again.
     
    Last edited: Jan 23, 2019
    glenneroo likes this.
  3. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    Has nobody else come across this? How does everyone else handle the switch between VR and non-VR?
     
  4. LT23Live

    LT23Live

    Joined:
    Jul 8, 2014
    Posts:
    85
    Separate EXE's is what I've seen.
     
  5. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    I contacted support:
    "None" doesn't provide any way of detecting if a headset is connected (as assumed), while the "Hmd Not Found" messages is thrown by OpenVR and can't be caught/isn't caught by Unity.

    The solution I'm currently using and which is easier (to maintain, imo) than two exporting two different exes with two different folders for basically the same code:
    Export with "None" first in the list and "OpenVR" second, then create two batch files (the original exe starts the app without VR) and put them in the folder the exe is in:
    1.
    Start myapp.exe -vrmode openvr

    2.
    Start myapp.exe -vrmode none


    This starts the app with the chosen mode, as if you'd put it first in the list for the current session.
    If the OpenVR version is started without a headset connected there's still going to be the "Hmd Not Found" error but there's really nothing I can do about that at the moment.

    If oneone has come up with a different solution, please feel free to share.
     
  6. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    65
    Is there really no better solution?
    I mean, this sucks
     
  7. glenneroo

    glenneroo

    Joined:
    Oct 27, 2016
    Posts:
    231
    I have found a solution for my use case - by using SteamVR SDK, which includes a simple check if a VR device is attached: OpenVR.IsHmdPresent() - don't forget import Valve.VR at the top!

    I am also using the CameraRig from SteamVR which includes a camera with decent default VR settings. Alongside this, I have a nearly identical 2nd camera. Depending on if VR is active or not, I change the MainCamera tag of each camera and disable/enable the VR/Non-VR cameras. This seems to work fine with a HTC Vive Pro but I haven't tested it with other headsets.
     
  8. geoinnovacion

    geoinnovacion

    Joined:
    Jul 16, 2019
    Posts:
    1
  9. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    404
    Sounds like it could be an issue. My understanding is that there should be a fallback mechanism in place for it to step through the list if the current one fails for any reason. Could you file a bug with a repro project attached and post the number here so we can do an investigation in that behavior?
     
    d1favero likes this.