Esempio n. 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;
        }
        /// <summary>
        /// Requests a fade on exit
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator ExitFade()
        {
            SetAudioListener(false);
            if (_exitFadeDuration > 0f)
            {
                MMLoadingSceneDebug("MMLoadingSceneManagerAdditive : exit fade, duration : " + _exitFadeDuration);
                MMSceneLoadingManager.LoadingSceneEvent.Trigger(_sceneToLoadName, MMSceneLoadingManager.LoadingStatus.ExitFade);
                OnExitFade?.Invoke();

                if (_fadeMode == FadeModes.FadeOutThenIn)
                {
                    MMFadeInEvent.Trigger(_exitFadeDuration, _exitFadeTween, FaderID, true);
                }
                else
                {
                    MMFadeOutEvent.Trigger(_exitFadeDuration, _exitFadeTween, FaderID, true);
                }
                yield return(MMCoroutine.WaitForUnscaled(_exitFadeDuration));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Calls a fader on entry
        /// </summary>
        /// <returns></returns>
        protected virtual IEnumerator EntryFade()
        {
            if (_entryFadeDuration > 0f)
            {
                MMLoadingSceneDebug("MMLoadingSceneManagerAdditive : entry fade, duration : " + _entryFadeDuration);
                MMSceneLoadingManager.LoadingSceneEvent.Trigger(_sceneToLoadName, MMSceneLoadingManager.LoadingStatus.EntryFade);
                OnEntryFade?.Invoke();

                if (_fadeMode == FadeModes.FadeOutThenIn)
                {
                    yield return(null);

                    MMFadeOutEvent.Trigger(_entryFadeDuration, _entryFadeTween, FaderID, true);
                }
                else
                {
                    yield return(null);

                    MMFadeInEvent.Trigger(_entryFadeDuration, _entryFadeTween, FaderID, true);
                }

                yield return(MMCoroutine.WaitFor(_entryFadeDuration));
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Test method triggered by an inspector button
 /// </summary>
 protected virtual void FadeIn1Second()
 {
     MMFadeInEvent.Trigger(1f, DefaultTween, ID, IgnoreTimescale, DebugWorldPositionTarget.transform.position);
 }
Esempio n. 5
0
 /// <summary>
 /// Test method triggered by an inspector button
 /// </summary>
 protected virtual void FadeIn1Second()
 {
     MMFadeInEvent.Trigger(1f, new MMTweenType(MMTween.MMTweenCurve.LinearTween));
 }
Esempio n. 6
0
 /// <summary>
 /// Test method triggered by an inspector button
 /// </summary>
 protected virtual void FadeIn1Second()
 {
     MMFadeInEvent.Trigger(1f);
 }