editor button to skip current room and pass to the next
This commit is contained in:
@@ -7,7 +7,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Editor
|
|||||||
public class EngineEditor : EditorWindow
|
public class EngineEditor : EditorWindow
|
||||||
{
|
{
|
||||||
private bool _registeredUpdateEvent;
|
private bool _registeredUpdateEvent;
|
||||||
private Button _passToNextRoomButton, _skipCurrentRoomButton;
|
private Button _passToNextRoomButton, _skipCurrentRoomButton, _skipAndPassButton;
|
||||||
|
|
||||||
[MenuItem("Window/Engine Editor")]
|
[MenuItem("Window/Engine Editor")]
|
||||||
public static void ShowEditor()
|
public static void ShowEditor()
|
||||||
@@ -28,6 +28,11 @@ namespace EscapeRoomEngine.Engine.Runtime.Editor
|
|||||||
text = "Skip Current Room"
|
text = "Skip Current Room"
|
||||||
};
|
};
|
||||||
rootVisualElement.Add(_skipCurrentRoomButton);
|
rootVisualElement.Add(_skipCurrentRoomButton);
|
||||||
|
_skipAndPassButton = new Button(SkipAndPass)
|
||||||
|
{
|
||||||
|
text = "Skip Current And Pass To Next Room"
|
||||||
|
};
|
||||||
|
rootVisualElement.Add(_skipAndPassButton);
|
||||||
|
|
||||||
EditorApplication.playModeStateChanged += _ => UpdateUI();
|
EditorApplication.playModeStateChanged += _ => UpdateUI();
|
||||||
UpdateUI();
|
UpdateUI();
|
||||||
@@ -51,6 +56,16 @@ namespace EscapeRoomEngine.Engine.Runtime.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SkipAndPass()
|
||||||
|
{
|
||||||
|
if (EditorApplication.isPlaying)
|
||||||
|
{
|
||||||
|
Engine.DefaultEngine.CurrentRoom.Match(some: room => room.SkipRoom());
|
||||||
|
Engine.DefaultEngine.HidePreviousRoom();
|
||||||
|
UpdateUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateUI()
|
private void UpdateUI()
|
||||||
{
|
{
|
||||||
if (EditorApplication.isPlaying)
|
if (EditorApplication.isPlaying)
|
||||||
@@ -68,6 +83,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Editor
|
|||||||
|
|
||||||
_passToNextRoomButton.SetEnabled(EditorApplication.isPlaying && Engine.DefaultEngine.NumberOfRooms > 1);
|
_passToNextRoomButton.SetEnabled(EditorApplication.isPlaying && Engine.DefaultEngine.NumberOfRooms > 1);
|
||||||
_skipCurrentRoomButton.SetEnabled(EditorApplication.isPlaying && Engine.DefaultEngine.NumberOfRooms > 0);
|
_skipCurrentRoomButton.SetEnabled(EditorApplication.isPlaying && Engine.DefaultEngine.NumberOfRooms > 0);
|
||||||
|
_skipAndPassButton.SetEnabled(EditorApplication.isPlaying && Engine.DefaultEngine.NumberOfRooms > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user