module state game objects
This commit is contained in:
@@ -6,9 +6,10 @@ namespace Escape_Room_Engine.Engine.Scripts.Editor
|
||||
{
|
||||
public class EngineEditor : EditorWindow
|
||||
{
|
||||
private Button _generateRoomButton, _skipCurrentRoomButton;
|
||||
private bool _registeredUpdateEvent;
|
||||
private Button _passToNextRoomButton, _skipCurrentRoomButton;
|
||||
|
||||
[MenuItem("Window/Engine/Engine Editor")]
|
||||
[MenuItem("Window/Engine Editor")]
|
||||
public static void ShowEditor()
|
||||
{
|
||||
var window = GetWindow<EngineEditor>();
|
||||
@@ -17,11 +18,11 @@ namespace Escape_Room_Engine.Engine.Scripts.Editor
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
_generateRoomButton = new Button(GenerateRoom)
|
||||
_passToNextRoomButton = new Button(PassToNextRoom)
|
||||
{
|
||||
text = "Generate Room"
|
||||
text = "Pass To Next Room"
|
||||
};
|
||||
rootVisualElement.Add(_generateRoomButton);
|
||||
rootVisualElement.Add(_passToNextRoomButton);
|
||||
_skipCurrentRoomButton = new Button(SkipCurrentRoom)
|
||||
{
|
||||
text = "Skip Current Room"
|
||||
@@ -32,12 +33,11 @@ namespace Escape_Room_Engine.Engine.Scripts.Editor
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
private void GenerateRoom()
|
||||
private void PassToNextRoom()
|
||||
{
|
||||
if (EditorApplication.isPlaying)
|
||||
{
|
||||
Engine.DefaultEngine.HideOldestRoom();
|
||||
Engine.DefaultEngine.GenerateRoom();
|
||||
Engine.DefaultEngine.HidePreviousRoom();
|
||||
UpdateUI();
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,20 @@ namespace Escape_Room_Engine.Engine.Scripts.Editor
|
||||
|
||||
private void UpdateUI()
|
||||
{
|
||||
_generateRoomButton.SetEnabled(EditorApplication.isPlaying);
|
||||
if (EditorApplication.isPlaying)
|
||||
{
|
||||
if (!_registeredUpdateEvent)
|
||||
{
|
||||
Engine.DefaultEngine.UpdateUIEvent += UpdateUI;
|
||||
_registeredUpdateEvent = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_registeredUpdateEvent = false;
|
||||
}
|
||||
|
||||
_passToNextRoomButton.SetEnabled(EditorApplication.isPlaying && Engine.DefaultEngine.NumberOfRooms > 1);
|
||||
_skipCurrentRoomButton.SetEnabled(EditorApplication.isPlaying && Engine.DefaultEngine.NumberOfRooms > 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user