using System; using UnityEngine; namespace AlicizaX.UI { /// /// Transform 旋转状态控制 /// 控制对象的本地欧拉角旋转 /// [Serializable] [ControlerStateName("Transform/Rotation")] [ControlerStateAttachType(true)] public class TransformRotationState : ControllerStateBase { [SerializeField] private Vector3 _rotation; [HideInInspector] [SerializeField] private Vector3 _defaultRotation; public override void Init(UXControllerStateRecorder recorder) { if (recorder != null && recorder.transform != null) { _defaultRotation = recorder.transform.localEulerAngles; } } public override void Execute(UXControllerStateRecorder recorder, int entryIndex, int selectionIndex) { if (recorder != null && recorder.transform != null) { recorder.transform.localEulerAngles = (entryIndex == selectionIndex) ? _rotation : _defaultRotation; } } public override bool Valid(UXControllerStateRecorder recorder) { return recorder != null && recorder.transform != null; } public override string GetDescription() { return $"匹配时: 旋转={_rotation}, 默认={_defaultRotation}"; } } }