Hello,
I’m working on a project using Unity 2021.2.11f1 and I’m facing a weird issue where loading the scene asynchronously never completes if allowSceneActivation is set to false in the asyncOperation.
Here is my custom scene loading method
private IEnumerator LoadScene(string sceneName, LoadSceneMode loadMode, bool enableOnLoad = false)
{
//If the scene name is empty or if there is scene load already in progress, just exit
if (sceneName.IsNullOrWhitespace() || _loadSceneOperation != null && !_loadSceneOperation.isDone)
yield return null;
//Load scene asynchronously
_loadSceneOperation = SceneManager.LoadSceneAsync(sceneName, loadMode);
//BUG: Currently setting allowSceneActivation to false causes the scene loading to get stuck and never call the OnSceneLoaded event
_loadSceneOperation.allowSceneActivation = enableOnLoad;
_loadSceneOperation.completed += SceneLoadingOperationCompleted;
while (_loadSceneOperation != null && !_loadSceneOperation.isDone)
yield return null;
}
And here is how I call it
StartCoroutine(LoadScene(MainSceneName, LoadSceneMode.Additive));
The AsyncOperation never finishes and SceneManager.sceneLoaded event never gets triggered.
And in the editor the scene shows up as ‘is loading’ perpetually
If anyone has any idea, please advice!