I have a very simple function that is called from other places to load a scene async, just passing in the buildIndex. It works fine. Then, I decided to create a mirror of that function, for scene unloading. And it doesn’t work, no matter how I tweak it.
public static IEnumerator Unload(int buildIndex)
{
Debug.Log("Unloading " + buildIndex);
if (buildIndex >= 0)
{
AsyncOperation operation = SceneManager.UnloadSceneAsync(buildIndex);
yield return new WaitWhile(() => !operation.isDone);
Debug.Log("good to go");
// extra code here
}
}
The “good to go” is never logged, even though the scene is visually unloaded.
I’ve tried replacing the WaitWhile
with other types of yields, with no success. Is there anything specific to sceneUnloading that makes it not continue the coroutine steps?