com.alicizax.unity.animatio.../Runtime/Core/Animation/UISizeDelta.cs

68 lines
1.4 KiB
C#
Raw Normal View History

2025-03-14 16:33:44 +08:00
using UnityEngine;
namespace AlicizaX.AnimationFlow.Runtime
{
[Category("RectTransform")]
public class UISizeDelta : ActionNode
{
public float duration = 1f;
public EaseType easyType;
public RectTransform target;
public bool setFrom;
public Vector2 from;
public Vector2 to;
protected Vector2 orgValue;
protected Vector2 enterValue;
public override void OnInit()
{
orgValue = target.sizeDelta;
}
public override void OnReset()
{
target.sizeDelta = orgValue;
}
public override void OnEnter()
{
if (setFrom)
{
target.sizeDelta = from;
}
2025-03-14 17:33:35 +08:00
if (Condition())
{
target.sizeDelta = to;
}
2025-03-14 16:33:44 +08:00
enterValue = target.sizeDelta;
}
public override void OnUpdate(float dt)
{
target.sizeDelta = Easing.Ease(easyType, enterValue, to, elapsedTime / duration);
}
public override bool Valid()
{
2025-03-14 16:39:52 +08:00
return target != null;
2025-03-14 16:33:44 +08:00
}
public override float Duration()
{
return duration;
}
public override bool HasSubTitle()
{
return true;
}
public override string SubTitle()
{
return target != null ? target.name : null;
}
}
}