60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using UnityEngine;
|
|
|
|
namespace AlicizaX.AnimationFlow.Runtime {
|
|
[Category("Property"), Name("Transform")]
|
|
public class TransformProperty : ActionNode {
|
|
public Transform target;
|
|
public bool setPosition = true;
|
|
public Vector3 position;
|
|
public bool setScale;
|
|
public Vector3 scale;
|
|
public bool setRotation;
|
|
public Vector3 rotation;
|
|
private Vector3 orgPosition;
|
|
private Vector3 orgScale;
|
|
private Vector3 orgRotation;
|
|
|
|
public override void OnInit() {
|
|
orgPosition = target.localPosition;
|
|
orgScale = target.localScale;
|
|
orgRotation = target.eulerAngles;
|
|
}
|
|
|
|
public override void OnReset() {
|
|
if (setPosition) {
|
|
target.localPosition = orgPosition;
|
|
}
|
|
if (setScale) {
|
|
target.localScale = orgScale;
|
|
}
|
|
if (setRotation) {
|
|
target.eulerAngles = orgRotation;
|
|
}
|
|
}
|
|
|
|
public override void OnEnter() {
|
|
if (setPosition) {
|
|
target.localPosition = position;
|
|
}
|
|
if (setScale) {
|
|
target.localScale = scale;
|
|
}
|
|
if (setRotation) {
|
|
target.eulerAngles = rotation;
|
|
}
|
|
}
|
|
|
|
public override bool Valid() {
|
|
return target != null;
|
|
}
|
|
|
|
public override bool HasSubTitle() {
|
|
return true;
|
|
}
|
|
|
|
public override string SubTitle() {
|
|
return target != null ? target.name : null;
|
|
}
|
|
}
|
|
}
|