Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Anonymous's avatar
Anonymous
6 years ago

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

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.

4 Replies

Replies have been turned off for this discussion
  • rh_galaxy's avatar
    rh_galaxy
    Heroic Explorer
    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.
  • 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.
  • Anonymous's avatar
    Anonymous


    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_galaxy's avatar
    rh_galaxy
    Heroic Explorer
    Ah, yes, I forgot to mention that I use singleton pattern in the GameManager class.