DESKTOP-SAJ6RKV\Administrator 2eeb4a98de 1
2025-05-30 15:07:24 +08:00

61 lines
1.6 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using UnityEngine.UI;
using TEngine;
using TMPro;
using DG.Tweening;
using Cysharp.Threading.Tasks;
namespace GameLogic
{
[Window(UILayer.UI)]
class UIPlayerAddNumItem : UIWidget
{
#region
private TextMeshProUGUI m_tmp_addNum;
protected override void ScriptGenerator()
{
m_tmp_addNum = FindChildComponent<TextMeshProUGUI>("m_tmp_addNum");
}
#endregion
#region
#endregion
protected override void OnCreate()
{
base.OnCreate();
// 实现字体的从小到大的变化、并且带有从0-1的透明变化
if (m_tmp_addNum != null)
{
// 初始缩放和透明
m_tmp_addNum.transform.localScale = Vector3.one * 0.2f;
var color = m_tmp_addNum.color;
color.a = 0f;
m_tmp_addNum.color = color;
// 动画缩放到1透明到1
float duration = 1f;
m_tmp_addNum.transform.DOScale(Vector3.one * 2, duration).SetEase(Ease.OutBack);
DOTween.To(
() => m_tmp_addNum.color.a,
a =>
{
var c = m_tmp_addNum.color;
c.a = a;
m_tmp_addNum.color = c;
},
1f, duration
).SetEase(Ease.OutQuad).OnComplete(async () =>
{
await UniTask.Delay(1000);
Destroy();
});
}
}
}
}