Loading scene with LoadSceneAsync freezes and progress jumps from 0% to 90%

I’ve setup some async scene loading with LoadSceneAsync method to play around with it but apparently it doesn’t do anything ‘asynchronous’. I copy pasted code from official Unity page so there’s no mistake on my part. Here’s the code

    public IEnumerator LoadScene(Level _level)
    {
        AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(GetSceneName(_level), LoadSceneMode.Single);
        asyncOperation.allowSceneActivation = false;
        Debug.Log("Loading progress: " + asyncOperation.progress);//should get 0 here, right?

        while (!asyncOperation.isDone)
        {
            Debug.Log("Loading progress: " + (asyncOperation.progress * 100) + "%");

            if (asyncOperation.progress >= 0.9f)
            {
                Debug.Log("Press the space bar to continue");

                if (Input.GetKeyDown(KeyCode.Space))
                    asyncOperation.allowSceneActivation = true;
            }

            yield return null;
        }
    }

You would imagine to get at least few frames of update while the scene loads, so you could update progress bar or something but it’s doesn’t, just straight freeze from 0% to 90% (then it waits for scene activation). Anyone know how to make this while loop run with the scene load?

I have to agree with the original post that there is a problem here. Even if the scene is small, the progress shouldn’t go like this… (from my logs):
0 (frame 1)
0 (frame 2)
0.1696721 (frame 3)
0.6801639 (frame 4)
0.9 (for 34 frames)
Then finally isDone = true.
If this was truly asynchronous, whatever Unity is doing during those 34 frames of 0.9 should be spread out more.

My solution is to estimate the load time (by testing), and then manually smooth it out like this:

var sceneLoader = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);

float elapsed = 0.0f;

// The amount of time to spread the loading progress over.
// If the actual time is longer than this, then it will sit at maxSceneLoadProgress until it's actually finished.
// If shorter, then it will jump to maxSceneLoadProgress when finished.
// This results in a smoother scene loading progress meter than using sceneLoader.progress, which jumps quickly to 0.9 then sits on that for a while before actually finishing.
const float MAX_ELAPSE = 2.0f;

do
{
	setProgressMeter(Mathf.Clamp01(elapsed / MAX_ELAPSE) * maxSceneLoadProgress);
	yield return null;
	elapsed += Time.deltaTime;
} while (!sceneLoader.isDone);

setProgressMeter(maxSceneLoadProgress);

Your scene is too small, it must be large enough to be able to see the difference. So you may have to keep the allowSceneActivation parameter to be wrong, then smooth the progress value manually. Most games use the following procedure to load scenes.

  1. Fading the screen to black.
  2. Load “LoadingSene” in Single mode.
  3. Fading the screen to “LoadingScene”.
  4. Load new scenes in Single mode, delay the activation of the new scene.
  5. Fading the screen to black.
  6. Activate the new scene.
  7. Fading the screen to a new scene.

every time i try make a question give me an error!!!

how to change the languages and voices and dialogue from start menu and connect it to all scenes?

my problem is in main menu options languages i want a script that when i choose a language from multi languages system the voices and dialogue and texts change to the language what selected from the menu i wanna a way that’s don’t make ma game bigger cuz i tried a way that duplicate the game size i tried to do a lot of canvases and in every canvas the language change and alot of game scenes every scene with a voice and dialogue of the chosen language that was hard take long time cuz that i wanna an easy way