Search Unity

How do I check if SteamVR is installed and Vive is connected?

Discussion in 'AR/VR (XR) Discussion' started by Jason-H, Jun 1, 2017.

  1. Jason-H

    Jason-H

    Joined:
    Nov 5, 2010
    Posts:
    87
    I have a game that can be run in desktop mode and VR mode. The main menu loads in desktop mode to start with as I have set the first entry in the Virtual Reality SDKs list in Player Settings to “None”.

    There is a checkbox on the menu to state whether you want to play the game in VR. When the toggle is on and the player clicks Start I then call
    Code (CSharp):
    1. VRSettings.LoadDeviceByName(“OpenVR”)
    and after yielding a frame
    Code (CSharp):
    1. VRSettings.enabled = true;
    This is fine for when the Vive is working however if the user doesn’t have SteamVR installed or the Vive is not connected to their computer I want the checkbox to be disabled. How can I do this?

    I know you can check the various states of VR using
    Code (CSharp):
    1. VRDevice.isPresent
    2. VRSettings.isDeviceActive
    3. VRDevice.model
    however these all come back either false or null before I have loaded the device and set VRSettings.enabled to true (something I can't do until they tick the checkbox and load the game).

    (Unity Answers post)
     
    BiomotionLab likes this.