Beispiel #1
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 = _defaultAlpha;
     _currentDuration    = DefaultDuration;
 }
        /// <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));
            }
        }
Beispiel #4
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));
            }
        }
 /// <summary>
 /// Test method triggered by an inspector button
 /// </summary>
 protected virtual void FadeIn1Second()
 {
     MMFadeInEvent.Trigger(1f, DefaultTween, ID, IgnoreTimescale, DebugWorldPositionTarget.transform.position);
 }
 /// <summary>
 /// When catching an MMFadeInEvent, we fade our image in
 /// </summary>
 /// <param name="fadeEvent">Fade event.</param>
 public virtual void OnMMEvent(MMFadeInEvent fadeEvent)
 {
     StartFading(MaskScale.y, MaskScale.x, fadeEvent.Duration, fadeEvent.Curve, fadeEvent.ID,
                 fadeEvent.IgnoreTimeScale, fadeEvent.WorldPosition);
 }
Beispiel #7
0
 /// <summary>
 /// When catching an MMFadeInEvent, we fade our image in
 /// </summary>
 /// <param name="fadeEvent">Fade event.</param>
 public virtual void OnMMEvent(MMFadeInEvent fadeEvent)
 {
     StartCoroutine(StartFading(true, fadeEvent.Duration, fadeEvent.Curve, fadeEvent.ID,
                                fadeEvent.IgnoreTimeScale, fadeEvent.WorldPosition));
 }
Beispiel #8
0
 /// <summary>
 /// When catching an MMFadeInEvent, we fade our image in
 /// </summary>
 /// <param name="fadeEvent">Fade event.</param>
 public virtual void OnMMEvent(MMFadeInEvent fadeEvent)
 {
     StartFading(InactiveAlpha, ActiveAlpha, fadeEvent.Duration, fadeEvent.Curve, fadeEvent.ID, fadeEvent.IgnoreTimeScale);
 }
Beispiel #9
0
 /// <summary>
 /// Test method triggered by an inspector button
 /// </summary>
 protected virtual void FadeIn1Second()
 {
     MMFadeInEvent.Trigger(1f, new MMTweenType(MMTween.MMTweenCurve.LinearTween));
 }
Beispiel #10
0
 /// <summary>
 /// Test method triggered by an inspector button
 /// </summary>
 protected virtual void FadeIn1Second()
 {
     MMFadeInEvent.Trigger(1f);
 }