unity scenemanager loadscene async code example
Example 1: unity scenemanager loadscene
using UnityEngine;
using UnityEngine.SceneManagement;
public class ExampleClass : MonoBehaviour
{
void Start()
{
SceneManager.LoadScene("OtherSceneName", LoadSceneMode.Additive);
}
}
Example 2: unity LoadSceneAsync get scene
Scene reference; bool isLoading; IEnumerator LoadScene(string sceneName) { this.isLoading = false; AsyncOperation op = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive); while (this.isLoading) { if (op.isDone) { this.isLoading = false; this.reference = SceneManager.GetSceneByName(sceneName); } yield return 0; } }