Persist Google Cardboard forward direction across scene loads in Unity3D 4.6.7?

江枫思渺然 提交于 2019-12-01 07:08:09

问题


I'm having trouble trying to maintain what Google Cardboard considers forward for the device after a scene load. Although I can't find any obvious call to this in the SDK c# code, it appears that the Google Cardboard SDK will automatically call Recenter after each scene load. I've tried calling DontDestroyOnLoad on the cardboard instantiated prefab, and on the Cardboard.SDK object (which is mentioned on line 328 of Cardboard.cs). This persists those objects across the load, but the view is still re-centered based on the current orientation of the device.

I want to avoid the recenter because some of the gaze-based menu items that can initiate a load are off to the user's left or right - which then makes the new center be to the left/right after the scene load. The user then has to physically move their body to be facing towards the new forward.

Is anyone else attempting the same thing? Am I missing something obvious?

Any suggestions very much appreciated!


回答1:


The function Cardboard.OnLevelWasLoaded() calls device.Reset(), which in the base class implementation just calls Recenter(), which has the effect you are seeing. If you comment out that line, or guard it with a variable you can control, the facing should not reset.




回答2:


I had the same problem but on Gear VR (Unity 5). In case anyone else is looking for this, I've answered it here.

Briefly, if you're also using OVR Utilities from Oculus:

  1. Locate the OVR Manager script attached to the OVRCameraRig
  2. Uncheck 'Reset Tracker On Load'


来源:https://stackoverflow.com/questions/31395888/persist-google-cardboard-forward-direction-across-scene-loads-in-unity3d-4-6-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!