UniversalViewer/Assets/Scripts/RuntimeGizmo/Objects/Commands/HandleTransformCommand.cs

36 lines
1.3 KiB
C#
Raw Normal View History

2024-04-21 22:38:26 +08:00
using RuntimeGizmos;
using UnityEngine;
public class HandleTransformCommand : TransformCommand
{
protected UIHandle _handle;
protected int _frame;
public HandleTransformCommand(TransformGizmo transformGizmo, Transform transform) : base(transformGizmo, transform.GetComponent<UIHandle>().Target)
{
_frame = TimelineController.Instance.CurrentFrame;
_handle = transform.GetComponent<UIHandle>();
}
public HandleTransformCommand(TransformGizmo transformGizmo, HandleUndoData data) : base(transformGizmo, data.NewPosition)
{
_frame = TimelineController.Instance.CurrentFrame;
_handle = data.Handle;
oldValues = new TransformValues() { position = data.OldPosition.Position, rotation = Quaternion.Euler(data.OldPosition.Rotation), scale = data.OldPosition.Scale };
newValues = new TransformValues() { position = transform.position, rotation = transform.rotation, scale = transform.localScale };
}
public override void Execute()
{
TimelineController.SetCurrentFrame(_frame);
base.Execute();
_handle.Owner.SetKeyframe();
}
public override void UnExecute()
{
TimelineController.SetCurrentFrame(_frame);
base.UnExecute();
_handle.Owner.SetKeyframe();
}
}