Example #1
0
    public static IEnumerator FadeOut(this CanvasGroup group, MonoBehaviour behaviour = null, float waitDuration = 0, float fadeDuration = 3f, Action finishedCallback = null)
    {
        behaviour = behaviour ?? AutoMonoBehaviour.Instantiate(group.gameObject);
        IEnumerator coroutine = StartFadeOut(group, waitDuration, fadeDuration, finishedCallback);

        behaviour.StartCoroutine(coroutine);
        return(coroutine);
    }
Example #2
0
    public static AudioSourceFadeState FadeOut(this AudioSource source, MonoBehaviour behaviour = null, float waitDuration = 0f, float fadeDuration = 3f, bool stopOnFinished = true, Action finishedCallback = null)
    {
        behaviour = behaviour ?? AutoMonoBehaviour.Instantiate(source.gameObject);
        AudioSourceFadeState fadeState = new AudioSourceFadeState(source);

        behaviour.StartCoroutine(StartFadeOut(source, waitDuration, fadeDuration, stopOnFinished, finishedCallback, fadeState));

        return(fadeState);
    }
 public static void FadeOut(this SpriteRenderer spriteRenderer, MonoBehaviour behaviour = null, float waitDuration = 0f, float fadeDuration = 3f, bool destroyOnFinished = true, Action finishedCallback = null)
 {
     behaviour = behaviour ?? AutoMonoBehaviour.Instantiate(spriteRenderer.gameObject);
     behaviour.StartCoroutine(StartFadeOut(spriteRenderer, waitDuration, fadeDuration, destroyOnFinished, finishedCallback));
 }