So i’ve had this problem in both unity 5.3.2 and 5.3.4 now, it was working a while back but when I tested it today it no longer works and I have no idea why.
I have my oculus turned un and the config util runninng in the background. I try the oculus demo scene… works. Try my game in the editor, works just fine. Compile and build my game, turn it on, does not start in oculus mode. Ever!
Checked out the logs and there are no errors. It even says
[VRDevice] Successfully created device
stereo.
I’ve even tried implementing my own code to turn it on
if(VRDevice.isPresent==true)
{
Debug.Log("A VR DEVICE HAS BEEN DETECTED FFS!");
VRSettings.enabled = true;
VRSettings.showDeviceView = true;
}
It prints out that message in the log, no errors thrown, but the game still doesn’t start in oculus mode.
Any ideas, suggestions?
Thanks for your time.
EDIT: To provide a little update on this. I’ve made the following code:
if (VRDevice.isPresent == true)
{
Debug.Log("BEFORE SETTING: "+VRDevice.family + " - " + VRDevice.model);
VRSettings.loadedDevice = VRDeviceType.Oculus;
Debug.Log("AFTER SETTING: "+VRDevice.family + " - " + VRDevice.model);
Debug.Log("A VR DEVICE HAS BEEN DETECTED FFS!");
VRSettings.enabled = true;
Debug.Log("VRSETTINGS shows as: " + VRSettings.enabled);
VRSettings.showDeviceView = true;
Debug.Log("VRSETTINGS showdeviceview: " + VRSettings.enabled);
}
This is what i get in the editor:
A VR DEVICE HAS BEEN DETECTED FFS!
UnityEngine.Debug:Log(Object)
splashScreenAnimation:Start() (at
Assets/scripts/splashscreen/splashScreenAnimation.cs:52)BEFORE SETTING: oculus - Oculus Rift
DK2 UnityEngine.Debug:Log(Object)
splashScreenAnimation:Update() (at
Assets/scripts/splashscreen/splashScreenAnimation.cs:80)AFTER SETTING: oculus - Oculus Rift
DK2 UnityEngine.Debug:Log(Object)
splashScreenAnimation:Update() (at
Assets/scripts/splashscreen/splashScreenAnimation.cs:82)A VR DEVICE HAS BEEN DETECTED FFS!
UnityEngine.Debug:Log(Object)
splashScreenAnimation:Update() (at
Assets/scripts/splashscreen/splashScreenAnimation.cs:83)VRSETTINGS shows as: True
UnityEngine.Debug:Log(Object)
splashScreenAnimation:Update() (at
Assets/scripts/splashscreen/splashScreenAnimation.cs:85)VRSETTINGS showdeviceview: True
UnityEngine.Debug:Log(Object)
splashScreenAnimation:Update() (at
Assets/scripts/splashscreen/splashScreenAnimation.cs:87)
That’s awesome, that’s what I expect! Nothing wrong Now for the compiled game:
[VRDevice] Successfully created device
stereo. A VR DEVICE HAS BEEN DETECTED
FFS! (Filename:
C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp
Line: 37)Setting up 1 worker threads for
Enlighten. Thread → id: 3758 →
priority: 1 BEFORE SETTING: stereo -
(Filename:
C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp
Line: 37)AFTER SETTING: stereo - (Filename:
C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp
Line: 37)A VR DEVICE HAS BEEN DETECTED FFS!
(Filename:
C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp
Line: 37)VRSETTINGS shows as: False
(Filename:
C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp
Line: 37)VRSETTINGS showdeviceview: False
(Filename:
C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp
Line: 37)
Soooo something’s wrong with the compiled game not detecting my oculus properly. But I’m not sure really what to do from here
EDIT 2: Okay bodged together a solution!
It seems that for some reason, my built code of unity is unable to detect what VR headset I have connected, but it can detect one is connected, returning a result of empty string for the headset model. Thus i’ve implemented the following code:
if(VRDevice.isPresent==true && string.IsNullOrEmpty(VRDevice.model))
{
Debug.Log("EMPTY VR DEVICE DETECTED!");
VRSettings.loadedDevice = VRDeviceType.Oculus;
VRSettings.enabled = true;
VRSettings.showDeviceView = true;
}
Which works fine for now. I’m pretty sure the problem is isolated to just my PC since it was working before without a problem so this shouldn’t affect too many people.
In the future I will want to add steam VR support so what i’m going to do is change the code above to just display a message of “VR Headset not Recognized” and then have a command line parameter to force on different types of VR headsets.
So for now, I guess I answered my own question… But if anyone figures out why this is happening, please let me and everyone else know.