using System.Collections; using DG.Tweening; using UnityEngine; using UnityEngine.UI; namespace AibisDream.Framework { public static class FadeKit { public static IEnumerator FadeInAsync(this Image image, float duration) { image.gameObject.SetActive(true); var tweener = image.DOBlendableColor(Color.white, duration); yield return tweener.WaitForCompletion(); } public static void FadeIn(this Image image, float duration) { image.gameObject.SetActive(true); var tweener = image.DOBlendableColor(Color.white, duration); } public static IEnumerator FadeOutAsync(this Image image, float duration) { image.gameObject.SetActive(true); var tweener = image.DOBlendableColor(Color.clear, duration); yield return tweener.WaitForCompletion(); image.gameObject.SetActive(false); } public static void FadeOut(this Image image, float duration) { image.gameObject.SetActive(true); image.DOBlendableColor(Color.clear, duration).onComplete += () => { image.gameObject.SetActive(false); }; } } }