Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

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

Application.LoadLevelAdditiveAsync

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

Description

Loads the level additively and asynchronously in the background.

Unlike LoadLevelAsync, LoadLevelAdditiveAsync does not destroy objects in the current level. Objects from the new level are added to the current scene. This is useful for creating continuous virtual worlds, where more content is loaded in as you walk through the environment.

Unity will completely load all assets and all objects in the scene in a background loading thread. This allows you to 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 LoadLevelAdditiveAsync can also be used to yield in a coroutine.

When building a player Unity automatically optimizes assets in such a way that LoadLevelAdditiveAsync 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 "MyAddLevel".
		var async : AsyncOperation = Application.LoadLevelAdditiveAsync ("MyAddLevel");
		yield async;
		Debug.Log ("Loading complete");
	}
using UnityEngine;
using System.Collections;

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

public class ExampleClass(MonoBehaviour):

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