using JetBrains.Annotations; using LLM.Editor.Helper; using UnityEditor; using UnityEngine; namespace LLM.Editor.Commands { public enum EditorTargetState { Play, Pause, Stop } [System.Serializable] public class SetEditorStateParams { public EditorTargetState state; } [UsedImplicitly] public class SetEditorStateCommand : ICommand { private readonly SetEditorStateParams _params; public SetEditorStateCommand(string jsonParams) { _params = jsonParams?.FromJson(); } public CommandOutcome Execute(Data.CommandContext context) { if (_params == null) { Debug.LogError("[SetEditorStateCommand] Invalid parameters."); return CommandOutcome.Error; } switch (_params.state) { case EditorTargetState.Play: EditorApplication.EnterPlaymode(); break; case EditorTargetState.Pause: EditorApplication.isPaused = true; break; case EditorTargetState.Stop: EditorApplication.ExitPlaymode(); break; } Debug.Log($"[SetEditorStateCommand] Set editor state to: {_params.state}"); return CommandOutcome.Success; } } }