1
\$\begingroup\$

I am trying to halt my level scenes from fully loading until I press a button to start the level but for some odd reason when I call LoadSceneAsync on my Additive levels and set those operations' allowSceneActivation value to false, it STILL loads the scene regardless. Why does this happen?

public IEnumerator StartNewLevel() { _sceneCounter = 0; SceneField startScene = LevelSceneGroup.StartScene; SceneField firstWave = LevelSceneGroup.LevelScenes[_sceneCounter++]; AsyncOperation startSceneOperation = SceneManager.LoadSceneAsync(startScene, LoadSceneMode.Additive); startSceneOperation.allowSceneActivation = false; AsyncOperation firstWaveSceneOperation = SceneManager.LoadSceneAsync(firstWave, LoadSceneMode.Additive); firstWaveSceneOperation.allowSceneActivation = false; //need to load 1st wave of level as well while (!firstWaveSceneOperation.isDone && !startSceneOperation.isDone) { Debug.Log(firstWaveSceneOperation.progress); Debug.Log(startSceneOperation.progress); yield return null; } } 

It loads only for one frame it seems and then the scenes immediately activate based on the console logs: screenshot of console logs

I have a button to start the loading of the scenes in the main menu. Another button is supposed to appear that will start the actual level and activate all of the scenes.

Before start of load:

enter image description here

After start of load; notice how Level1_start and Level1_wave are complete instead of loading despite allowSceneActivation set to false:

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ Just to make sure, you are starting StartNewLevel with a coroutine, right? \$\endgroup\$ Commented Sep 18, 2024 at 17:57
  • \$\begingroup\$ @Zibelas yes its being called with StartCoroutine(StartNewLevel()) \$\endgroup\$ Commented Sep 18, 2024 at 18:17
  • \$\begingroup\$ Note that according to the documentation, setting startSceneOperation.allowSceneActivation = false; should also prevent startSceneOperation.isDone from becoming true. The actual way to check if the scene was loaded completely is if (startSceneOperation.progress >= 0.9f). Knowing this does of course not solve your current problem, but it might help you to fix the next one. \$\endgroup\$ Commented Sep 19, 2024 at 10:59

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.