public IEnumerator LoadScene(SceneNumbers currentScene, SceneNumbers sceneToLoad) { // Put up loading screen loading.SetActive(true); // Load required and wait for it to finish loading _loadSceneAsync = SceneManager.LoadSceneAsync((int)sceneToLoad); _asyncOps.Add(_loadSceneAsync); _loadSceneAsync.allowSceneActivation = false; StartCoroutine(WaitSceneLoad(currentScene)); yield break; }
IEnumerator WaitSceneLoad(SceneNumbers currentScene) { while (!_loadSceneAsync.isDone) { if (_loadSceneAsync.progress >= 0.9f) { // Once the required scene is loaded then unload current loading.SetActive(false); _loadSceneAsync.allowSceneActivation = true; } yield return(null); } }
public void ChangeTarget(SceneNumbers targetScene) { sceneToChangeInto = targetScene; }