- Home /
Unity app crashes if Oculus isn't worn
I've come across this annoying bug recently and was hoping someone here might have an idea about this.
I'm developing an app on Oculus CV1, using Unity 5.4.3f3, and every time I try to start playing and the Oculus isn't worn, the app just freezes and eventually crashes. This only happens on a build(PC) and not in the editor, where it runs fine even when the sensor doesn't detect a user in the headset.
Having the headset on when starting play and removing it afterwards works as intended and doesn't freeze or crash(Though it blacks out the screen, which I assume is a Unity thing?). However it still causes weird behaviours when doing so(Seems like when I'm rewearing it, it initializes all over again, and detects other cameras that aren't suppose to be tied to an oculus, like the minimap, though that's probably unrelated).
Right now we're using a workaround where we put a small sticker on the sensor so it always thinks a user is present, but that's a dirty hack.
Anyone know anything about this? Maybe it's a Unity/Oculus issue that's resolved in a newer version?
Any help is appreciated. Thanks.
Answer by bcsquared · Apr 01, 2017 at 06:59 AM
I have been experiencing the same issue and have not found a real fix. In the meantime, I've put tape on the inner sensor and I physically move the headset every couple minutes to keep it awake. If I find a real fix, I'll let you know.
Okay, I just found a "fix" that is working for me. 1. Check "Run in Background" in Player settings. 2. In the OVR$$anonymous$$anager script, set isUserPresent = true;
If there's another true fix out there, please inform me/us. Until then, I will continue to test with this method.
Answer by meat5000 · Mar 28, 2017 at 10:44 PM
I will assume that the player detection sensor signal is interpreted as Device On and Off in Unity for whatever reason. Perhaps there is some other implementation that is absent or misused, I don't know, I haven't looked in to it. I did read earlier in the Holographic docs that including 'None' as the default option in your Virtual SDKs entry in settings allows Unity to run in Vanilla, without Device. Of course this means that when the Player Detection is triggered you will probably need to manually initialise the Device in your code, even from the outset. I guess this follows that you should assume that at Runtime, Device is always in an Off state and will always require Initialisation.
You've probably seen this page, but just in case...
https://docs.unity3d.com/ScriptReference/VR.VRSettings.LoadDeviceByName.html
It suggests the need the VRSettings.enabled the device. Again, don't know if you're already doing this ;)