diff --git a/Runtime/Core/Animation/UISizeDelta.cs b/Runtime/Core/Animation/UISizeDelta.cs new file mode 100644 index 0000000..94d09d8 --- /dev/null +++ b/Runtime/Core/Animation/UISizeDelta.cs @@ -0,0 +1,62 @@ +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; + } + + enterValue = target.sizeDelta; + } + + public override void OnUpdate(float dt) + { + target.sizeDelta = Easing.Ease(easyType, enterValue, to, elapsedTime / duration); + } + + public override bool Valid() + { + return target != null && duration > 0; + } + + public override float Duration() + { + return duration; + } + + public override bool HasSubTitle() + { + return true; + } + + public override string SubTitle() + { + return target != null ? target.name : null; + } + } +} diff --git a/Runtime/Core/Animation/UISizeDelta.cs.meta b/Runtime/Core/Animation/UISizeDelta.cs.meta new file mode 100644 index 0000000..5737f0c --- /dev/null +++ b/Runtime/Core/Animation/UISizeDelta.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f371fc3375d34f16996a235b1b659f90 +timeCreated: 1741941042 \ No newline at end of file