Files
aibis-dream/Assets/Scripts/Framework/OtherKit/FadeKit.cs
T
dingyuntian 9f20ef52d8 UI工具翻新
1. 增加UI工具
2. 增加设置页面
3. GameLoop更新
4. 导入ActionKit工具
2025-04-21 18:53:30 +08:00

40 lines
1.2 KiB
C#

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);
};
}
}
}