1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- 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<SetEditorStateParams>();
- }
- 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;
- }
- }
- }
|