sceneName | Nombre o ruta de la escena a cargar. |
sceneBuildIndex | Indice de la escena en los Build Settings a cargar. |
mode | Si LoadSceneMode.Single entonces todas las escenas actuales serán descargadas antes de cargarse. |
AsyncOperation Utilice AsyncOperation para determinar si la operación ha completado.
Carga la escena asincronicamente en el fondo.
The given scene name can either be the full scene path, the path shown in the Build Settings window or just the scene name. If only the scene name is given this will load the first scene in the list that matches. If you have multiple scenes with same name but different paths, you should use the full scene path.
Examples of supported formats:
"Assets/Scenes/Scene1.unity"
"Scenes/Scene1"
"Scene1"
Tenga en cuenta que esto es sensible a mayúsculas.
using System.Collections; using UnityEngine; using UnityEngine.SceneManagement;
public class Example : MonoBehaviour { void Update() { //Press the space key to start coroutine if (Input.GetKey(KeyCode.Space)) { //Use a coroutine to load the Scene in the background StartCoroutine(LoadYourAsyncScene()); } }
IEnumerator LoadYourAsyncScene() { // The Application loads the Scene in the background at the same time as the current Scene. //This is particularly good for creating loading screens. You could also load the scene by build //number. AsyncOperation asyncLoad = SceneManager.LoadSceneAsync("Scene2");
//Wait until the last operation fully loads to return anything while (!asyncLoad.isDone) { yield return null; } } }