private void Fade(Script_SpriteFadeOut mySprite) { if (isFadeIn) { // mySprite.SetVisibility(false); StartCoroutine(mySprite.FadeInCo(null, fadeTime, alphaTarget)); } else { // mySprite.SetVisibility(true); StartCoroutine(mySprite.FadeOutCo(null, fadeTime, alphaTarget)); } }
/// <summary> /// Ensures other coroutine stops running /// Check if we're already fading out /// /// Note: This gameobject must be active to call this method (to run coroutine). /// </summary> public void FadeOut() { if (fadeInCoroutine != null) { StopCoroutine(fadeInCoroutine); fadeInCoroutine = null; } if (fadeOutCoroutine != null) { return; } float t = Script_Utils.GetFadeTime(fadeSpeed); fadeOutCoroutine = StartCoroutine(spriteFader.FadeOutCo( null, t )); }
public void FadeOut(Action cb, float?_fadeTime = null) { float fadeTime = _fadeTime ?? Script_Utils.GetFadeTime(fadeSpeed); StartCoroutine(spriteFader.FadeOutCo(cb, fadeTime)); }
private void HandleFadeOut() { if (fadeOutAxis == FadeOutAxis.None) { return; } if (CheckBounds()) { FadeIn(); } else { FadeOut(); } /// <summary> /// Ensure other coroutine stops running /// Check if we're already fading out /// </summary> void FadeOut() { if (fadeInCoroutine != null) { StopCoroutine(fadeInCoroutine); fadeInCoroutine = null; } if (isFadedOut || fadeOutCoroutine != null) { return; } float t = Script_Utils.GetFadeTime(fadeSpeed); isFadedIn = false; fadeOutCoroutine = StartCoroutine(spriteFader.FadeOutCo( () => { isFadedOut = true; }, t )); } void FadeIn() { // if is fully faded out, then upon fading in, match up with player position if (isFadedOut) { InitializeState(); } if (fadeOutCoroutine != null) { StopCoroutine(fadeOutCoroutine); fadeOutCoroutine = null; } if (isFadedIn || fadeInCoroutine != null) { return; } float t = Script_Utils.GetFadeTime(fadeSpeed); isFadedOut = false; fadeInCoroutine = StartCoroutine(spriteFader.FadeInCo( () => { isFadedIn = true; }, t )); } }