// Update is called once per frame void Update() { if (toReturnToMain) { print("toReturnToMain is true"); timeElapsed += Time.deltaTime; if (timeElapsed > delalBeforeReturningToMain) { UnityEngine.SceneManagement.SceneManager.LoadScene((int)ScenesState.MainWindow); currentLoadedScene = ScenesState.MainWindow; print("scene manager - returned to main window"); toReturnToMain = false; } } }
IEnumerator SceneSwitcher(int sceneIndex) { try { UnityEngine.SceneManagement.SceneManager.LoadScene(sceneIndex, LoadSceneMode.Additive); currentLoadedScene = (ScenesState)sceneIndex; UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(gameObject, UnityEngine.SceneManagement.SceneManager.GetSceneByBuildIndex(sceneIndex)); toReturnToMain = true; } catch (Exception e) { print("Could not load " + (ScenesState)sceneIndex + " scene."); print(e); } yield return(null); }
// Start is called before the first frame update void Start() { UnityEngine.SceneManagement.SceneManager.LoadScene((int)ScenesState.MainWindow); currentLoadedScene = ScenesState.MainWindow; print("scene manager - start"); }