Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Application.LoadLevelAsync

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function LoadLevelAsync(index: int): AsyncOperation;
public static AsyncOperation LoadLevelAsync(int index);
public static def LoadLevelAsync(index as int) as AsyncOperation
public static function LoadLevelAsync(levelName: string): AsyncOperation;
public static AsyncOperation LoadLevelAsync(string levelName);
public static def LoadLevelAsync(levelName as string) as AsyncOperation

Description

Loads the level asynchronously in the background.

Unity will completely load all assets and all objects in the scene in a background loading thread. This allows you to load new levels while still playing the current one, show a progress bar or create a completely streaming world where you constantly load and unload different parts of the world based on the player position, without any hiccups in game play.

isDone variable from the resulting AsyncOperation can be used to query if the level load has completed. The result of a LoadLevelAsync can also be used to yield in a coroutine.

When building a player Unity automatically optimizes assets in such a way that LoadLevelAsync will load them from disk linearly to avoid seek times. Note that background loading performance in the Unity Editor is much lower than in the web player or standalone build. In the Editor you might also get more loading hiccups than in the player.

This function requires Unity Pro.

	function Start () {
		// Load the level named "MyBigLevel".
		var async : AsyncOperation = Application.LoadLevelAsync ("MyBigLevel");
		yield async;
		Debug.Log ("Loading complete");
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    IEnumerator Start() {
        AsyncOperation async = Application.LoadLevelAsync("MyBigLevel");
        yield return async;
        Debug.Log("Loading complete");
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Start() as IEnumerator:
		async as AsyncOperation = Application.LoadLevelAsync('MyBigLevel')
		yield async
		Debug.Log('Loading complete')