diff --git a/Assets/_Scripts/Managers/GameStateManager/GameStateController.cs b/Assets/_Scripts/Managers/GameStateManager/GameStateController.cs index 017bd57..18d0d65 100644 --- a/Assets/_Scripts/Managers/GameStateManager/GameStateController.cs +++ b/Assets/_Scripts/Managers/GameStateManager/GameStateController.cs @@ -1,9 +1,5 @@ using UnityEngine; -#if UNITY_EDITOR -using UnityEditor; -#endif - public class GameStateController : MonoBehaviour { [Tooltip("Selected state will be applied when the game starts or on the button press")] @@ -22,24 +18,7 @@ public class GameStateController : MonoBehaviour // Change game state back to entry state when exiting playing mode GameStateManager.Instance.ChangeState(GameState.Enter); } -} -#if UNITY_EDITOR -[CustomEditor(typeof(GameStateController))] -class GameStateControllerEditor : Editor -{ - public override void OnInspectorGUI() - { - DrawDefaultInspector(); - - var gameStateController = (GameStateController)target; - if (gameStateController == null) return; - - // Custom button to change game state from inspector during runtime - if (GUILayout.Button("Change State")) - { - if (Application.isPlaying) GameStateManager.Instance.ChangeState(gameStateController.ChangeToState); - } - } -} -#endif \ No newline at end of file + public void ChangeState(string newStateStr) => + GameStateManager.Instance.ChangeState((GameState) System.Enum.Parse(typeof(GameState), newStateStr)); +} \ No newline at end of file diff --git a/Assets/_Scripts/Managers/GameStateManager/GameStateController_CustomEditor.cs b/Assets/_Scripts/Managers/GameStateManager/GameStateController_CustomEditor.cs new file mode 100644 index 0000000..6944635 --- /dev/null +++ b/Assets/_Scripts/Managers/GameStateManager/GameStateController_CustomEditor.cs @@ -0,0 +1,24 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +#endif + +#if UNITY_EDITOR +[CustomEditor(typeof(GameStateController))] +class GameStateControllerEditor : Editor +{ + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + var gameStateController = (GameStateController)target; + if (gameStateController == null) return; + + // Custom button to change game state from inspector during runtime + if (GUILayout.Button("Change State")) + { + if (Application.isPlaying) GameStateManager.Instance.ChangeState(gameStateController.ChangeToState); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/_Scripts/Managers/GameStateManager/GameStateController_CustomEditor.cs.meta b/Assets/_Scripts/Managers/GameStateManager/GameStateController_CustomEditor.cs.meta new file mode 100644 index 0000000..3f87a77 --- /dev/null +++ b/Assets/_Scripts/Managers/GameStateManager/GameStateController_CustomEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 515312156c02a0c279cced733921e2f3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: