private void Awake() { OnPlaySceneLoaded += StartGame; // Play scene is already loaded. if (SceneManager.GetSceneByName(playScene).IsValid()) { OnPlaySceneLoaded.Invoke(); return; } StartCoroutine(LoadPlayScene()); }
/// <summary> /// Loads the play scene and sets it as the active one. /// </summary> /// <returns></returns> IEnumerator LoadPlayScene() { var ls = SceneManager.LoadSceneAsync(playScene, LoadSceneMode.Additive); while (!ls.isDone) { yield return(null); } yield return(null); SceneManager.SetActiveScene(SceneManager.GetSceneByName(playScene)); OnPlaySceneLoaded.Invoke(); }