- Home /
How to switch between OVRManagers' between async scene transition?
Hello everybody,
I'm developing a VR game in our studio, and one of the issues I've experienced is when loading a new scene the players' controller is not responding.
The component responsible for controllers input is OVRManager.cs on the OVRCameraRig.
this component is a singleton. In case I have two OVRCameraRigs in my scene, one will automatically get destroyed.
Now the issue: I use LoadSceneAsync in my game, using the "additive" mode. This means that the next scene is loaded "on top" of the current scene and the current scene is "unloaded async" once the new scene is fully loaded.
During this process, the OVRManager.cs on the next scene is deleted because at this point in time there are two OVRManager.cs in the game.
my solution was to find the current OVRManager.cs in the game and destroy it once button pressed to load next scene. but it's not always working.
What other approach should I consider?
Answer by rh_galaxy · Feb 08, 2020 at 06:21 PM
This is how I have solved it. Have a GameManager script that is singleton (and 'Do not destroy') that controls the game state machine, and scene transitions. Also have a CameraController script, and attach both to a CameraHolder object in the Inspector. Add the OVRManager component to CameraHolder. See image showing this at runtime.
Now you will have only one camera that lives between scenes one OVRManager and one overseeing GameManager. The same idea will work for steamvr as well.
Hi @rh_galaxy I have also unique camera in each scene so cannot play with this change. I could parent the new camera to the "CameraHolder" and change the position on each scene. I wrote a script that searches for the OVR$$anonymous$$anager.cs component and assign it to LoadScene script, so the LoadScene script knows which OVR$$anonymous$$anager to kill on scene change. $$anonymous$$y LoadScene.cs component is also a singleton and 'Do Not Destroy'
It seems to be working properly...