Exemple #1
0
 /// <summary>
 /// Triggered when the actual loading is done, replaces the progress bar with the complete animation
 /// </summary>
 protected virtual void LoadingComplete()
 {
     LoadingSceneEvent.Trigger(_sceneToLoad, LoadingStatus.LoadComplete);
     LoadingCompleteAnimation.gameObject.SetActive(true);
     //StartCoroutine(MMFade.FadeCanvasGroup(LoadingProgressBar, 0.1f, 0f));
     //StartCoroutine(MMFade.FadeCanvasGroup(LoadingAnimation, 0.1f, 0f));
     //StartCoroutine(MMFade.FadeCanvasGroup(LoadingCompleteAnimation, 0.1f, 1f));
 }
Exemple #2
0
 /// <summary>
 /// Call this static method to load a scene from anywhere
 /// </summary>
 /// <param name="sceneToLoad">Level name.</param>
 public static void LoadScene(string sceneToLoad)
 {
     _sceneToLoad = sceneToLoad;
     Application.backgroundLoadingPriority = ThreadPriority.High;
     if (LoadingScreenSceneName != null)
     {
         LoadingSceneEvent.Trigger(sceneToLoad, LoadingStatus.LoadStarted);
         SceneManager.LoadScene(LoadingScreenSceneName);
     }
 }
Exemple #3
0
        /// <summary>
        /// Loads the scene to load asynchronously.
        /// </summary>
        protected virtual IEnumerator LoadAsynchronously()
        {
            // we setup our various visual elements
            LoadingSetup();

            // we fade from black
            //MMFadeOutEvent.Trigger(StartFadeDuration, _tween);
            yield return(new WaitForSeconds(StartFadeDuration));

            // we start loading the scene
            _asyncOperation = SceneManager.LoadSceneAsync(_sceneToLoad, LoadSceneMode.Single);
            _asyncOperation.allowSceneActivation = false;

            // while the scene loads, we assign its progress to a target that we'll use to fill the progress bar smoothly
            while (_asyncOperation.progress < 0.9f)
            {
                _fillTarget = _asyncOperation.progress;
                yield return(null);
            }
            // when the load is close to the end (it'll never reach it), we set it to 100%
            _fillTarget = 1f;

            // we wait for the bar to be visually filled to continue
            while (_progressBarImage.fillAmount != _fillTarget)
            {
                yield return(null);
            }

            // the load is now complete, we replace the bar with the complete animation
            LoadingComplete();
            yield return(new WaitForSeconds(LoadCompleteDelay));

            // we fade to black
            //MMFadeInEvent.Trigger(ExitFadeDuration, _tween);
            yield return(new WaitForSeconds(ExitFadeDuration));

            // we switch to the new scene
            _asyncOperation.allowSceneActivation = true;
            LoadingSceneEvent.Trigger(_sceneToLoad, LoadingStatus.NewSceneLoaded);
        }
Exemple #4
0
        private IEnumerator LoadAsynchronously()
        {
            LoadingSetup();

            _asyncOperation = SceneManager.LoadSceneAsync(_sceneToLoad, LoadSceneMode.Single);
            _asyncOperation.allowSceneActivation = false;

            while (_asyncOperation.progress < 0.9f)
            {
                _fillTarget = _asyncOperation.progress;
                yield return(null);
            }
            _fillTarget = 1f;

            LoadingComplete();
            yield return(new WaitForSeconds(_loadCompleteDelay));

            // MMfadeInevene.trigger
            yield return(new WaitForSeconds(_exitFadeDuration));

            // 새로운 scene으로 교체
            _asyncOperation.allowSceneActivation = true;
            LoadingSceneEvent.Trigger(_sceneToLoad, LoadingStatus.NewSceneLoaded);
        }
Exemple #5
0
 private void LoadingComplete()
 {
     LoadingSceneEvent.Trigger(_sceneToLoad, LoadingStatus.LoadComplete);
 }