/// <summary> /// Start FadeInOut Sequence (Alpha) /// </summary> public void FadeInOut(float fadeTo = 1f, float fadeInSpeed = 1.2f, float fadeOutSpeed = 2.5f, float fadeOutTime = 3f, bool SingleFade = false, DisableTypeAfter disableTypeAfter = DisableTypeAfter.Disable, FadeOutAfter fadeOutAfter = FadeOutAfter.Bool) { FadeObj.SetActive(true); outAfter = fadeOutAfter; m_Alpha = 0; m_fadeTo = fadeTo; m_fadeInSpeed = fadeInSpeed; m_fadeOutSpeed = fadeOutSpeed; m_fadeOutTime = fadeOutTime; startFadeIn = true; startFadeOut = false; fadedIn = false; fadedOut = false; colorFade = false; disableType = disableTypeAfter; single = SingleFade; fadeCompleted = false; start = true; time = 0; }
/// <summary> /// Start FadeInOut Sequence (Alpha) /// </summary> public IEnumerator StartFadeIO(float startAlpha, float fadeInSpeed, float fadeInMax = 1f, float fadeOutSpeed = 2.5f, float fadeOutTime = 3f, FadeOutAfter fadeOutAfter = FadeOutAfter.Bool) { float alpha = startAlpha; m_Alpha = startAlpha; m_fadeSpeed = fadeInSpeed; fadeCompleted = false; fadeOut = false; fadedIn = false; alpha = 0; m_Alpha = 0; while (alpha <= fadeInMax) { alpha += Time.fixedDeltaTime * m_fadeSpeed; m_Alpha = alpha; yield return(null); } alpha = fadeInMax; m_Alpha = alpha; m_fadeSpeed = fadeOutSpeed; fadedIn = true; if (fadeOutAfter == FadeOutAfter.Bool) { yield return(new WaitUntil(() => fadeOut)); } else { yield return(new WaitForSecondsRealtime(fadeOutTime)); } while (alpha >= 0.1f) { alpha -= Time.fixedDeltaTime * m_fadeSpeed; m_Alpha = alpha; yield return(null); } alpha = 0; m_Alpha = alpha; yield return(new WaitUntil(() => alpha <= 0.05f)); fadeCompleted = true; yield return(null); }
/// <summary> /// Start FadeInOut Sequence /// </summary> public IEnumerator StartFadeIO(Color startColor, float fadeInSpeed, float fadeInMax = 1f, float fadeOutSpeed = 2.5f, float fadeOutTime = 3f, FadeOutAfter fadeOutAfter = FadeOutAfter.Bool) { Color color = startColor; m_fadeColor = startColor; m_fadeSpeed = fadeInSpeed; fadeCompleted = false; fadeOut = false; fadedIn = false; color.a = 0; m_fadeColor.a = 0; while (color.a <= fadeInMax) { color.a += Time.fixedDeltaTime * m_fadeSpeed; m_fadeColor = color; yield return(null); } color.a = fadeInMax; m_fadeColor = color; m_fadeSpeed = fadeOutSpeed; fadedIn = true; if (fadeOutAfter == FadeOutAfter.Bool) { yield return(new WaitUntil(() => fadeOut)); } else { yield return(new WaitForSecondsRealtime(fadeOutTime)); } while (color.a >= 0.1f) { color.a -= Time.fixedDeltaTime * m_fadeSpeed; m_fadeColor = color; yield return(null); } color.a = 0; m_fadeColor = color; yield return(new WaitUntil(() => color.a <= 0.05f)); fadeCompleted = true; yield return(null); }