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

59 lines
1.2 KiB
C#
Raw Normal View History

2025-02-07 16:05:13 +08:00
using UnityEngine;
namespace AlicizaX.AnimationFlow.Runtime
{
[Category("Animation")]
[System.Serializable]
2025-11-18 11:27:53 +08:00
public class TranslateTo : AnimationBaseNode<Vector3>
2025-02-07 16:05:13 +08:00
{
public Transform target;
public override void OnInit()
{
orgValue = target.localPosition;
}
public override void OnReset()
{
target.localPosition = orgValue;
}
public override void OnEnter()
{
if (setFrom)
{
target.localPosition = from;
}
enterValue = target.localPosition;
}
public override void OnUpdate(float dt)
{
target.localPosition = Easing.Ease(easyType, enterValue, to, elapsedTime / duration);
}
public override bool Valid()
{
Debug.Log(target != null && duration > 0);
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;
}
}
}