- Home /
Unable to detect rift,XR.XRSettings.enabled is returning false
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:
private void SetUPVR(){
bool VREnabled = UnityEngine.XR.XRSettings.enabled;
string VRDeviceName = UnityEngine.XR.XRSettings.loadedDeviceName;
if (UnityEngine.XR.XRDevice.GetNativePtr() != VRPtr)
{
VRPtr = UnityEngine.XR.XRDevice.GetNativePtr();
if (VRDeviceName == "Oculus")
{
//do stuff
}
else if (VRDeviceName == "OpenVR")
{
//do stuff
}
}
if ( VREnabled && VRDeviceName == "Oculus")
{
//do stuff
}
else if( VREnabled && VRDeviceName == "OpenVR")
{
//do stuff
}
}
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.