split into multiple assemblies
This commit is contained in:
73
Assets/Engine/Runtime/Editor/EngineEditor.cs
Normal file
73
Assets/Engine/Runtime/Editor/EngineEditor.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace EscapeRoomEngine.Engine.Runtime.Editor
|
||||
{
|
||||
public class EngineEditor : EditorWindow
|
||||
{
|
||||
private bool _registeredUpdateEvent;
|
||||
private Button _passToNextRoomButton, _skipCurrentRoomButton;
|
||||
|
||||
[MenuItem("Window/Engine Editor")]
|
||||
public static void ShowEditor()
|
||||
{
|
||||
var window = GetWindow<EngineEditor>();
|
||||
window.titleContent = new GUIContent("Engine Editor");
|
||||
}
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
_passToNextRoomButton = new Button(PassToNextRoom)
|
||||
{
|
||||
text = "Pass To Next Room"
|
||||
};
|
||||
rootVisualElement.Add(_passToNextRoomButton);
|
||||
_skipCurrentRoomButton = new Button(SkipCurrentRoom)
|
||||
{
|
||||
text = "Skip Current Room"
|
||||
};
|
||||
rootVisualElement.Add(_skipCurrentRoomButton);
|
||||
|
||||
EditorApplication.playModeStateChanged += _ => UpdateUI();
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
private void PassToNextRoom()
|
||||
{
|
||||
if (EditorApplication.isPlaying)
|
||||
{
|
||||
Engine.DefaultEngine.HidePreviousRoom();
|
||||
UpdateUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void SkipCurrentRoom()
|
||||
{
|
||||
if (EditorApplication.isPlaying)
|
||||
{
|
||||
Engine.DefaultEngine.CurrentRoom.Match(some: room => room.SkipRoom());
|
||||
UpdateUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateUI()
|
||||
{
|
||||
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