Skip to content

Commit d714de9

Browse files
committed
Save Play in Game Mode with cookie project
1 parent e9c6062 commit d714de9

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

engine/Sandbox.Tools/Editor/EditorMainWindow.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public void ShowCloseDialog()
104104
private Option discard;
105105
private Option undoOption;
106106
private Option redoOption;
107+
private Option gameMode;
107108

108109
internal EditorMainWindow()
109110
{
@@ -155,10 +156,9 @@ internal EditorMainWindow()
155156
var gameMenu = MenuBar.AddMenu( "Game" );
156157
gameMenu.AddOption( "Play", "play_arrow", EditorScene.TogglePlay, "editor.toggle-play" );
157158

158-
gameMenu.AddOption( new Option()
159+
gameMode = gameMenu.AddOption( new Option()
159160
{
160161
Checkable = true,
161-
Checked = EditorScene.PlayMode,
162162
Toggled = ( b ) => EditorScene.PlayMode = b,
163163
Text = "Play in Game Mode",
164164
Icon = "sports_esports"
@@ -309,6 +309,9 @@ internal void OnStartupLoadingFinished()
309309
// Load gizmo settings
310310
EditorScene.RestoreState();
311311

312+
// Load game mode value
313+
gameMode.Checked = EditorScene.PlayMode;
314+
312315
// Register our menu bar and dock options, doesn't open anything
313316
MenuBar.RegisterNamed( "Editor", MenuBar );
314317
DockAttribute.RegisterWindow( "Editor", this );

engine/Sandbox.Tools/Scene/EditorScene.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ public static class EditorScene
1010
/// <summary>
1111
/// Should the game start in play mode when hitting play, instead of playing the active scene.
1212
/// </summary>
13-
public static bool PlayMode { get; set; } = false;
13+
public static bool PlayMode
14+
{
15+
get => ProjectCookie?.Get( "editor.playmode", false ) ?? false;
16+
set => ProjectCookie?.Set( "editor.playmode", value );
17+
}
1418

1519
public static Gizmo.SceneSettings GizmoSettings { get; private set; } = new Gizmo.SceneSettings();
1620

0 commit comments

Comments
 (0)