- 引入 UnityGameFramework
- 使用 Luban 替代原来的 UGF 的数据表
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public static class UIExtension
|
||||
{
|
||||
public static IEnumerator FadeToAlpha(this CanvasGroup canvasGroup, float alpha, float duration)
|
||||
{
|
||||
float time = 0f;
|
||||
float originalAlpha = canvasGroup.alpha;
|
||||
while (time < duration)
|
||||
{
|
||||
time += Time.deltaTime;
|
||||
canvasGroup.alpha = Mathf.Lerp(originalAlpha, alpha, time / duration);
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
|
||||
canvasGroup.alpha = alpha;
|
||||
}
|
||||
|
||||
public static IEnumerator SmoothValue(this Slider slider, float value, float duration)
|
||||
{
|
||||
float time = 0f;
|
||||
float originalValue = slider.value;
|
||||
while (time < duration)
|
||||
{
|
||||
time += Time.deltaTime;
|
||||
slider.value = Mathf.Lerp(originalValue, value, time / duration);
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
|
||||
slider.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user