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