unity – How to delete a scene after the other one has been loaded

There is a function in Unity.SceneManagmentcalled SceneManager.LoadSceneASync (), which is used to determine if the loading operation is complete.

One way to use it would be to call a Coroutine, and make it run until the scene is fully charged. Once the loading operation is performed, the Unit will switch to the fully charged scene.

When you want to load the scene, you do it.

StartCoroutine (LoadYourAsyncScene ());

Then you create the coroutina:

IEnumerator LoadYourAsyncScene ()
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync ("YourSceneName"); // change "YourSceneName" with the scene you want to load

// wait until the scene is fully charged
while (! asyncLoad.isDone)
{
zero performance;
}
}