Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

What is the best practice for handling scene change in Unity?

DirtyOlegDirtyOleg Posts: 3
NerveGear
I am new to develop VR game. My setup is Unity 2018.4.14, Oculus SDK v12, I need some suggestions regarding the following questions:
1. Are making OVRCameraRig and OVRInputModule "DontDestroyOnLoad" a good practice? If not, what should I do, initializing everything each time there is a scene change?
2. Does Oculus SDK have API for fade in/out, which could be used during scene change.
3. What is a good way to pass data between different scene? currently I am using ScriptableObject.

Any suggestion is appreciated.

Comments

  • rh_galaxyrh_galaxy Posts: 118 Oculus Start Member
    edited January 11
    I can only answer for myself, but I have done this for my Oculus Rift game using Unity 2019.2 latest SDK.

    1. OVRCameraRig is DND or there will be times in the scene change that is without camera, I don't use OVRInputModule.
    2. Don't know, I did a cube as a child of the camera, in the OVRCameraRig prefab fading it myself by setting the material color black -> transparent. I do the fade to avoid visible freezes, the freezes happen during all black screen and cannot be seen. It was impossible to do LoadSceneAsync without framerate dips. But during loading that's ok by Oculus testing. This approach also works with the steamvr SDK for a steam version.
    3. I only have two scenes, a menu and the game levels, but have a GameManager script as DND that controls the scene changes and initializes their start up. This is also the games state machine.
  • FiveFingerStudiosFiveFingerStudios Posts: 70 Oculus Start Member
    The scene DontDestroyOnLoad is no longer recommended by Unity. make your own scene to hold any objects that must live between scenes and use the Singleton pattern to store that data.
  • DirtyOlegDirtyOleg Posts: 3
    NerveGear
    The scene DontDestroyOnLoad is no longer recommended by Unity. make your own scene to hold any objects that must live between scenes and use the Singleton pattern to store that data.
    But Singleton pattern still need to use DontDestroyOnLoad(), right?
  • rh_galaxyrh_galaxy Posts: 118 Oculus Start Member
    Ah, yes, I forgot to mention that I use singleton pattern in the GameManager class.
Sign In or Register to comment.