Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
 public void ChangeTarget(SceneNumbers targetScene)
 {
     sceneToChangeInto = targetScene;
 }