GearVR HMD Head Mounted detection stops working after a level reload
We are making a video playing application for the GearVR that relies on pausing the video if the headset is removed and playing when the headset is put back on. To make resetting the state of the video player easier, we are reloading the scene when the video finishes or when the user presses the back button.
However, the head mounting detection only works when the application is first loaded, and upon reloading the level the head mounting detection stops working. We've narrowed it down to either the Oculus plugin, or how Unity handles action mapping. We were just wondering if anyone else is having this issue or if anyone has a fix for it.
We are using Unity 5.6 and Oculus Utilities 1.13 and plugin 1.12 and have encountered the same issue on Oculus Utilities 1.12. We are unable to downgrade to Unity 5.5 because of our reliance on specific functions of the new native video player.
Thanks!
Answer by Codest19 · Apr 18, 2017 at 05:35 AM
Hello @Mammoth_VR,
I also have this issue. Can't detect player unmounting gear. I have it trying in the second scene in my game. Using Unity 5.6 and ovr 1.13. I've also noticed it doesn't call OnApplicationPause or OnApplicationQuit when taking off the gear and pulling out the phone. I need to save my game at that point obviously. Have you found a solution in the past few days?
Sorry for the late response. We found a workaround by creating a separate object that does not get unloaded (Using DontDestroyOnLoad) and having that manage anything that uses H$$anonymous$$D detection, it might work for your OnApplicationQuit as well. Only issues we've found is that we have to set all the variables back up when the level does load, which we did by using tags. I'm not sure what kind of game you're making, so our method might be inefficient. Sorry if this doesn't help.
Answer by BodhiPurplePill · Apr 20, 2017 at 12:31 AM
Try OVRManager's booleans "isUserPresent" or "hasVRFocus"
Answer by zainnn · Nov 13, 2017 at 04:41 AM
Hello @Mammoth_VR, I was having a similar problem where I was loading/restarting scenes upon OVRManager.HMDUnmounted , i was able to load the scene from another scene but was unable to reload the same level upon this event. I tried using "IsHmdPresent" and "HasVRFocus" in Update but they never worked. I finally got it working with "OVRManager.HMDUnmounted" event listener and i sorted out the problem was in Update function of my script. It was a simple transform script i was using in my Update but it seemed to override OVRManager.HMDUnmounted, so i replaced the script with an animation and it works like a charm now. I know it's a bit late to post but hope it can help you or anyone with similar issue.
Unity Version: 2017.3.0b6 Oculus Utilities : 1.19 Cheers