I am experiencing some weird behavior. I am making a VR game in Unity - I have a menu scene that is a full small level and when you press a UI element it loads another scene.
If I load the scenes individually then everything works perfectly - however, when I transition from the menu into the scene - the player controller position is changed. I wrote a script to fix this - however now when I go from the menu, to the scene, and back to the main menu, the player position there is changed. I even tried using a static class to determine if it is the first time the scene is loaded and to position things differently to try and overcome this behavior - but I think maybe I am just misunderstanding something. Is the player controller from the menu scene being taken into the second scene and maybe that is what is causing this weird position shift? When I come back to the menu level, one of the images also doesn’t fully load that does load when you first start the game.
I don’t understand why the process of loading the level does not simply load it fresh - and I am wondering if some scene state is being carried over even though I haven’t specifically programmed that?
In addition - some of what I looked at when searching for answers brought up LoadSceneAsync which I would love to use as this doesn’t block when clicking the menu item - but that is giving me weird behaviour too. From the menu scene if I LoadSceneAsync(“level”) that’s fine, but then if I try and LoadSceneAsync back to (“Menu”) it crashes. Using adb logcat, I can see that the error it gives is a Null Reference, DeadGameObject error. So does LoadSceneAsync destroy the scene it has just come from? I am confused why I am not seeing other people mention this as being a thing so I am sure I am just going wrong somewhere.
Loading A or B or C works fine. Using LoadScene going from A to B messes with the player position, but if I use a script to fix that then going A to B and back to A causes problems.
Using LoadSceneAsync going from A to B works fine. But going A to B back to A causes a crash saying A no longer exists.