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

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
onpocket
Posts: 13
Joined: Fri Feb 01, 2019 5:04 am

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

Post 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.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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.
onpocket
Posts: 13
Joined: Fri Feb 01, 2019 5:04 am

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

Post by onpocket »

That seems to have solved it, i do not know how i missed that...

Thank you so much!
Post Reply