Page 1 of 1

Persist LoadLevel()'s "levelName" variable across scenes

Posted: Wed Mar 20, 2019 1:41 pm
by onpocket
Hello!

Lately, i have been working on scene transitions in my project and i need to have a "main scene" that connects to a "loading scene" (for that using the LoadLevel() sequencer command), which by its turn (being a "lighter" scene) will start loading the "next level scene" with (UnityEngine.SceneManagement.SceneManager.LoadSceneAsync). To do this i need to be able to keep the LoadLevel()'s sequencer command "levelName" variable when i call this function from the "main scene", so that i can refer to it in my custom scene loader, which is essentially this line: "LoadSceneAsync(levelName)".

In my project i have one important limitation which is that i cannot rely on UI to fade in or fade out of scenes, i am saying this since i know there are some UI based alternatives to deal with scene transitions.

Re: Persist LoadLevel()'s "levelName" variable across scenes

Posted: Wed Mar 20, 2019 2:01 pm
by Tony Li
Hi,

You might want to use a Scene Transition Manager component as described here:


(At 4:40 if the video doesn't automatically jump there.)

The Scene Transition Manager can load a lightweight loading scene and then load the next level scene. You don't have to use on UI fades like the video does. Just specify the loading scene name.

Re: Persist LoadLevel()'s "levelName" variable across scenes

Posted: Thu Mar 21, 2019 7:57 am
by onpocket
That seems to have solved it, i do not know how i missed that...

Thank you so much!