KeepItUp/Assets/_Scripts/Managers/GameStateManager/GameStateController_CustomEditor.cs
2022-07-20 20:06:57 +03:00

24 lines
638 B
C#

#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