Search Unity

Unable to detect rift,XR.XRSettings.enabled is returning false

Discussion in 'AR/VR (XR) Discussion' started by immrATaylor, Jun 5, 2019.

  1. immrATaylor

    immrATaylor

    Joined:
    Mar 28, 2017
    Posts:
    26
    I have a project that I need to support both Oculus Rift and SteamVR.I am trying to upgrade it from 2017.2.0f3 to 2019.1.5. After upgrading I can't get it to recognize the rift.
    I have this code:

    Code (CSharp):
    1. private void SetUPVR(){
    2.       bool VREnabled =  UnityEngine.XR.XRSettings.enabled;
    3.       string VRDeviceName = UnityEngine.XR.XRSettings.loadedDeviceName;
    4.       if (UnityEngine.XR.XRDevice.GetNativePtr() != VRPtr)
    5.                         {
    6.                             VRPtr = UnityEngine.XR.XRDevice.GetNativePtr();
    7.                             if (VRDeviceName == "Oculus")
    8.                             {
    9.                                 //do stuff
    10.                             }
    11.                             else if (VRDeviceName == "OpenVR")
    12.                             {
    13.                                 //do stuff
    14.                             }
    15.                         }
    16.  
    17.                     if ( VREnabled && VRDeviceName == "Oculus")
    18.                     {
    19.                        //do stuff
    20.                     }
    21.                     else if( VREnabled && VRDeviceName == "OpenVR")
    22.                     {
    23.                      //do stuff
    24.                     }
    25.     }
    I have Virtual Reality Supported checked in the project settings. If I have both the Oculus SDK and the OpenVR SDK in the Virtual Reality SDKs section it always opens SteamVR when I press play in the editor even if I have Oculus at the top of the list. If I remove the OpenVR SDK from the list then UnityEngine.XR.XRSettings.enabled returns false and UnityEngine.XR.XRSettings.loadedDeviceName returns "". If OpenVR SDK is in the list enabled returns true and loadedDevice name always returns OpenVR. I don't even have a vVve plugged in, just the rift. Please help. Any and all help is appreciated.
     
  2. Sam_Space

    Sam_Space

    Joined:
    Jun 28, 2019
    Posts:
    16
    I am curious to know what's going on here as well.