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> /// Note: This gameobject must be active to call this method (to run coroutine). /// </summary> public void FadeIn() { // if is fully faded out, then upon fading in, match up with player position if (fadeOutCoroutine != null) { StopCoroutine(fadeOutCoroutine); fadeOutCoroutine = null; } if (fadeInCoroutine != null) { return; } float t = Script_Utils.GetFadeTime(fadeSpeed); fadeInCoroutine = StartCoroutine(spriteFader.FadeInCo( null, t )); }
public void FadeIn(Action cb, float?_fadeTime = null) { float fadeTime = _fadeTime ?? Script_Utils.GetFadeTime(fadeSpeed); StartCoroutine(spriteFader.FadeInCo(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 )); } }