54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
![]() |
using UnityEngine;
|
||
|
|
||
|
namespace AlicizaX.AnimationFlow.Runtime {
|
||
|
[Category("Animation")]
|
||
|
public class ScaleTo : ActionNode {
|
||
|
public float duration = 1f;
|
||
|
public EaseType easyType;
|
||
|
public Transform target;
|
||
|
public bool setFrom;
|
||
|
public Vector3 from;
|
||
|
public Vector3 to = Vector3.one;
|
||
|
|
||
|
protected Vector3 orgValue;
|
||
|
protected Vector3 enterValue;
|
||
|
|
||
|
public override void OnInit() {
|
||
|
orgValue = target.localScale;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
public override void OnReset() {
|
||
|
target.localScale = orgValue;
|
||
|
}
|
||
|
|
||
|
public override void OnEnter() {
|
||
|
if (setFrom) {
|
||
|
target.localScale = from;
|
||
|
}
|
||
|
enterValue = target.localScale;
|
||
|
}
|
||
|
|
||
|
public override void OnUpdate(float dt) {
|
||
|
target.localScale = 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;
|
||
|
}
|
||
|
}
|
||
|
}
|