|
|
|
|
|
|
if (!CheckLoadState(currentSceneName)) |
|
|
|
{ |
|
|
|
//Add the scene to the list of scenes to load asynchronously in the background
|
|
|
|
_scenesToLoadAsyncOperations.Add(SceneManager.LoadSceneAsync(currentSceneName, LoadSceneMode.Additive)); |
|
|
|
_scenesToLoadAsyncOperations.Add(SceneManager.LoadSceneAsync(currentSceneName, LoadSceneMode.Single)); |
|
|
|
} |
|
|
|
} |
|
|
|
_scenesToLoadAsyncOperations[0].completed += SetActiveScene; |
|
|
|
|
|
|
Scene scene = SceneManager.GetSceneAt(i); |
|
|
|
if (scene.name != _initializationScene.sceneName) |
|
|
|
{ |
|
|
|
Debug.Log("Added scene to unload = " + scene.name); |
|
|
|
//Add the scene to the list of the scenes to unload
|
|
|
|
_ScenesToUnload.Add(scene); |
|
|
|
} |
|
|
|
|
|
|
//Unload the scene asynchronously in the background
|
|
|
|
SceneManager.UnloadSceneAsync(_ScenesToUnload[i]); |
|
|
|
} |
|
|
|
_ScenesToUnload.Clear(); |
|
|
|
_ScenesToUnload.Clear(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> This function checks if a scene is already loaded </summary>
|
|
|
|