public void FadeScreenOut(Color fadeTo, FadeOutCallback callback, string sceneToLoad = null) { ResetFader(); OverlayRenderer.color = fadeTo; OverlayRenderer.enabled = true; StartCoroutine(FadeScreenOutCoroutine(callback, sceneToLoad)); }
public void FadeOut(FadeOutCallback fadeCallback = null) { fadeToBlack = true; if (fadeCallback != null) { callback += fadeCallback; } }
public void FadeScreenOut(Color fadeTo, FadeOutCallback callback) { Reset(); image.color = fadeTo; image.enabled = true; StartCoroutine( FadeScreenOutCoroutine(lerpSpeed, callback)); }
// Use this for initialization void Start() { fadeOverlay = GetComponentInChildren <Image>(); alpha = 1f; fadeToBlack = false; callback = null; FadeIn(); }
IEnumerator FadeScreenOutCoroutine(float speed, FadeOutCallback callback) { for (float t = 0f; t <= 1f; t += Time.unscaledDeltaTime * speed) { SetAlpha(t); yield return(null); } SetAlpha(opaque); FadeScreenOutCallback(callback); }
IEnumerator FadeScreenOutCoroutine(FadeOutCallback callback, string sceneToLoad) { FadeInProgress = true; for (float time = 0f; time <= duration; time += Time.smoothDeltaTime) { float t = Mathf.InverseLerp(0f, duration, time); SetAlpha(progression.Evaluate(t)); yield return(null); } SetAlpha(opaque); FadeScreenOutCallback(callback, sceneToLoad); FadeInProgress = false; }
public void FadeScreenOutCallback(FadeOutCallback callback) { switch (callback) { case FadeOutCallback.RestartScene: appManager.UnlockCursor(); appManager.RestoreTimescale(); appManager.RestartCurrentScene(); break; case FadeOutCallback.QuitApp: appManager.UnlockCursor(); appManager.Exit(); break; } }
// Update is called once per frame void Update() { if (fadeToBlack) { if (!fadeOverlay.gameObject.activeSelf) { alpha = 0f; fadeOverlay.gameObject.SetActive(true); } else if (alpha < 1f) { alpha = Mathf.Clamp01(alpha + ALPHA_STEP); Color newColor = fadeOverlay.color; newColor.a = alpha; fadeOverlay.color = newColor; if (alpha == 1f && callback != null) { callback(); callback = null; } } } else { if (alpha > 0f && fadeOverlay.gameObject.activeSelf) { alpha = Mathf.Clamp01(alpha - ALPHA_STEP); Color newColor = fadeOverlay.color; newColor.a = alpha; fadeOverlay.color = newColor; if (alpha == 0f) { fadeOverlay.gameObject.SetActive(false); } } } }
void FadeScreenOutCallback(FadeOutCallback callback, string sceneToLoad) { switch (callback) { case FadeOutCallback.RestartScene: SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); break; case FadeOutCallback.LoadScene: if (sceneToLoad == null) { Debug.LogError("ScreenFader callback attempts to load scene but scene name unspecified."); } else { SceneManager.LoadScene(sceneToLoad); } break; case FadeOutCallback.QuitApp: Application.Quit(); // implement via whatever controller of your game responsible break; } }
void setFadeOutCallback(FadeOutCallback fc) { this.fadeoutcallback = fc; }
public void FadeScreenOut(FadeOutCallback callback, string sceneToLoad = null) { FadeScreenOut(defaultFadeOutColor, callback, sceneToLoad); }
public void FadeScreenOut(FadeOutCallback callback) { FadeScreenOut(defaultColor, callback); }
/**************************************************************************************************/ /*! * \fn public void StartFadeOut(float sec, FadeOutCallback callback) * 音量フェードアウト開始 * \param sec : フェードアウト時間(秒) * \param callback : フェード完了時のコールバック(必要ない場合は null) * \date 2014.12.25(Thu) * \author Masayoshi.Matsuyama@Donuts */ /**************************************************************************************************/ public void StartFadeOut(float sec, FadeOutCallback callback = null) { Donuts.Sound.Utility.debPrint("EasyPlay:StartFadeOut:" + sec); switch(fadeMode) { case FadeMode.FadeIn: // フェードイン中なら現在の状況からフェードアウトを行う //fadeRate; // 時間はその分へらす if (sec > 0.0f) { sec = sec * fadeRate; } break; case FadeMode.None: fadeRate = 1.0f; break; case FadeMode.FadeOut: // フェードアウトを既にやってるなら無し Donuts.Sound.Utility.debPrint("ERROR:EasyPlay:already fading..."); return; } if (sec > 0.0f) { fadeSpeed = 1.0f / sec; } else { fadeSpeed = 2.0f; } fadeMode = FadeMode.FadeOut; fadeOutCallbackFunc = callback; Donuts.Sound.Utility.debPrint("EasyPlay:StartFadeOut:nowMode=" + fadeMode); }