Scene not loading properly?

So this isn’t 100% on-topic for this lecture (I finished the main lecture and I’m in the cleaning-up sprucing up phase and trying to make everything look nicer). I moved my portals a bit as a part of this, and now ever since, the scene isn’t loading properly whenever I try to load via the portal. The save and load IS working correctly otherwise. But, when I try to walk though the portal, it’s getting hung up somewhere in the
yield return SceneManager.LoadSceneAsync(sceneToLoad);
call. I can see in the inspector that it IS getting the scene, however for whatever reason, it’s never counted as being “loaded” so it gets hung up here indefinitely, and I’m extrememly confused and don’t know what’s happening. I tried to switch it to just using “LoadScene” but that causes, of course, race condition problems and the whole scene doesn’t load in correctly.

Any idea why LoadSceneAsync isn’t working properly? I’m really lost.

Is there any chance that there is a warning message in the console that reads something to the effect of:

DontDestroyOnLoad does not work on GameObjects that are not in the root of the heirarchy

You mentioned moving the portals a bit. While scene organization is normally a great idea (and I normally encourage it!), the portals have to be at the root of the scene (not a child of any other GameObject) or when DontDestroyOnLoad runs, it gives a warning (I wish Unity would issue an error for this!) and the object is not moved into the DontDestroyOnLoad Scene.

This means that once the new scene is loaded, the original portal is gone and the Transition coroutine just gives up.

1 Like

Thank you SO much! It wasn’t giving me the warning, but yeah, I had my portals underneath an empty parent object to keep the hierarchy cleaned up. Once I moved them out from there everything was working just fine! Yeah, it’s weird that Unity doesn’t have a built-in error that says something like “Object could not be placed into Don’t Destroy On Load list because this object is not in the hierarchy root” or something. That’s good to know though, thank you again so much!

It should have been in the warnings, but often we disable the warnings because we get tired of seeing nonsense warnings about variables not used, etc.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.