예제 #1
0
 /// <summary>
 /// Sets up all visual elements, fades from black at the start
 /// </summary>
 protected virtual void LoadingSetup()
 {
     MMFadeOutEvent.Trigger(StartFadeDuration, _tween);
     LoadingCompleteAnimation.alpha = 0;
     LoadingProgressBar.GetComponent <Image>().fillAmount = 0f;
     LoadingText.text = _loadingTextValue;
 }
예제 #2
0
 /// <summary>
 /// When catching an MMFadeOutEvent, we fade our image out
 /// </summary>
 /// <param name="fadeEvent">Fade event.</param>
 public virtual void OnMMEvent(MMFadeOutEvent fadeEvent)
 {
     _fading             = true;
     _fadeCounter        = 0f;
     _currentTargetAlpha = 0f;
     _currentDuration    = DefaultDuration;
 }
        /// <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));
            }
        }
        /// <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.LoadTransitionComplete);
        }
예제 #5
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));
            }
        }
예제 #6
0
 /// <summary>
 /// Test method triggered by an inspector button
 /// </summary>
 protected virtual void FadeOut1Second()
 {
     MMFadeOutEvent.Trigger(1f, DefaultTween, ID, IgnoreTimescale, DebugWorldPositionTarget.transform.position);
 }
예제 #7
0
 /// <summary>
 /// When catching an MMFadeOutEvent, we fade our image out
 /// </summary>
 /// <param name="fadeEvent">Fade event.</param>
 public virtual void OnMMEvent(MMFadeOutEvent fadeEvent)
 {
     StartFading(MaskScale.x, MaskScale.y, fadeEvent.Duration, fadeEvent.Curve, fadeEvent.ID,
                 fadeEvent.IgnoreTimeScale, fadeEvent.WorldPosition);
 }
예제 #8
0
 /// <summary>
 /// When catching an MMFadeOutEvent, we fade our image out
 /// </summary>
 /// <param name="fadeEvent">Fade event.</param>
 public virtual void OnMMEvent(MMFadeOutEvent fadeEvent)
 {
     StartCoroutine(StartFading(false, fadeEvent.Duration, fadeEvent.Curve, fadeEvent.ID,
                                fadeEvent.IgnoreTimeScale, fadeEvent.WorldPosition));
 }
예제 #9
0
 /// <summary>
 /// When catching an MMFadeOutEvent, we fade our image out
 /// </summary>
 /// <param name="fadeEvent">Fade event.</param>
 public virtual void OnMMEvent(MMFadeOutEvent fadeEvent)
 {
     StartFading(ActiveAlpha, InactiveAlpha, fadeEvent.Duration, fadeEvent.Curve, fadeEvent.ID, fadeEvent.IgnoreTimeScale);
 }
예제 #10
0
 /// <summary>
 /// Test method triggered by an inspector button
 /// </summary>
 protected virtual void FadeOut1Second()
 {
     MMFadeOutEvent.Trigger(1f, new MMTweenType(MMTween.MMTweenCurve.LinearTween));
 }
예제 #11
0
 /// <summary>
 /// Test method triggered by an inspector button
 /// </summary>
 protected virtual void FadeOut1Second()
 {
     MMFadeOutEvent.Trigger(1f);
 }