CodeBlanks Logo Icon CodeBlanks

Async loading

Learn to show a screen while loading a scene with LoadSceneAsync.

Asynchronous Scene Loading (LoadSceneAsync)

When loading heavy scenes, the synchronous LoadScene method can freeze the game for several seconds. SceneManager.LoadSceneAsync() executes the loading process asynchronously in the background.

using UnityEngine.SceneManagement;

// Asynchronous background loading without freeze
AsyncOperation op = SceneManager.LoadSceneAsync("LargeLevel");

The application remains responsive, enabling animated loading screens while the scene streams in.

AsyncOperation and Progress Bar

LoadSceneAsync returns an AsyncOperation object. Reading its operation.progress value (0.0 to 1.0) inside a coroutine loop directly drives a UI progress bar fillAmount.

IEnumerator LoadWithProgress(string sceneName) {
    AsyncOperation op = SceneManager.LoadSceneAsync(sceneName);
    while (!op.isDone) {
        float progress = op.progress;
        yield return null;
    }
}

This provides real-time visual feedback to players regarding how much of the level has loaded.

Practice Print async operation and progress info

Assign "LoadSceneAsync" to operation and "100%" to progress. Print Operation: LoadSceneAsync | Progress: 100% to the console.

Starter code

Player.cs
using System;

class Program
{
    static void Main()
    {
        // operation ve progress değerlerini tanımlayıp yazdır
    }
}

Sample solution

Player.cs
using System;

class Program
{
    static void Main()
    {
        string operation = "LoadSceneAsync";
        string progress = "100%";
        Console.WriteLine("Operation: " + operation + " | Progress: " + progress);
    }
}

Expected output

Operation: LoadSceneAsync | Progress: 100%

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which method is used to load heavy scenes asynchronously in the background without freezing the game?

  • SceneManager.LoadSceneAsync() Correct answer
  • SceneManager.FastLoad()
  • SceneManager.ThreadRun()
  • SceneManager.LoadSceneBlocking()

Explanation: LoadSceneAsync loads the scene asynchronously on background threads, keeping the primary viewport responsive.

2 Invoke asynchronous scene load

Question
AsyncOperation operation = SceneManager.____("Level2");
Answer
AsyncOperation operation = SceneManager.LoadSceneAsync("Level2");

Explanation: The LoadSceneAsync method is used to load a scene asynchronously in the background.

3 Async loading concepts

Term Meaning
LoadSceneAsync Loads scene in background without freeze
AsyncOperation Tracks status and progress of async op
operation.progress Loading progress between 0.0 and 1.0
Loading Screen Shows loading progress to the player

All lessons in Intermediate