Beispiel #1
0
        /// <summary>
        /// Loads the scene to load asynchronously.
        /// </summary>
        protected virtual IEnumerator LoadAsynchronously()
        {
            // we setup our various visual elements
            LoadingSetup();

            // 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 (LoadingProgressBar.GetComponent <Image>().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);
            yield return(new WaitForSeconds(ExitFadeDuration));

            // we switch to the new scene
            _asyncOperation.allowSceneActivation = true;
        }
Beispiel #2
0
 /// <summary>
 /// When catching an MMFadeInEvent, we fade our image in
 /// </summary>
 /// <param name="fadeEvent">Fade event.</param>
 public virtual void OnMMEvent(MMFadeInEvent fadeEvent)
 {
     _fading             = true;
     _fadeCounter        = 0f;
     _currentTargetAlpha = ActiveAlpha;
     _currentDuration    = DefaultDuration;
 }