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. Dismiss Notice

Resolved Detect whether a system is VR capable

Discussion in 'Multiplatform Dev Blitz Day 2023 - Q&A' started by PatHightreeXVR, Jun 22, 2023.

  1. PatHightreeXVR

    PatHightreeXVR

    Joined:
    Dec 10, 2018
    Posts:
    19
    I'm working on an app which can work in pancake and VR mode.
    We're having issues when a user enables VR functionality accidentally when the system doesn't support it.
    Can I detect whether any VR hardware abstraction layer like OpenXR, SteamVR, WMR or Oculus runtime is installed ?
     
  2. VRDave_Unity

    VRDave_Unity

    Unity Technologies

    Joined:
    Nov 19, 2021
    Posts:
    254
    Hey @PatHightreeXVR,
    This can be a bit tricky to solve. One option is to directly look for the runtimes you care to support. In the OpenXR package on Unity Editor for Windows we handle switching between OpenXR runtimes by using a Windows Registry key (look in the OpenXR package source for
    OpenXRRuntimeSelector
    ). You could add a similar detection mechanism directly to your VR app to attempt to detect if an OpenXR runtime is installed. In a similar fashion, you would need to check for other supported platforms if you wanted to use non-OpenXR packages for VR.

    On the flip side, even if they have SteamVR, WMR or Oculus installed, they may not have it on and equipment hooked up. For this you would have to rely on the results of the XR initialization calls. You can try to initialize and check if the loader succeeds or not. Here is some documentation on how to manually do this sort of thing. I would probably introduce a workflow to detect the runtimes first, then warn the user if they try to enable VR mode without detecting a runtime, then fallback to screen-space controls again if the initialization fails.
     
    PatHightreeXVR likes this.
  3. PatHightreeXVR

    PatHightreeXVR

    Joined:
    Dec 10, 2018
    Posts:
    19
    Hi Dave
    I think that being able to disable the VR option by detecting the absence of an OpenXR runtime already goes a long way.
    Thank you very much for the info!
     
    VRDave_Unity and DevDunk like this.