Add a new option when entering play mode to always restore to the editor window after exiting play mode. Also made it the default option on new projects.

This commit is contained in:
Jake Young
2026-08-07 16:08:29 -04:00
parent 70498fa42c
commit 6489b7d7b7
3 changed files with 22 additions and 5 deletions
@@ -287,6 +287,7 @@ namespace FlaxEditor.Modules
case Options.InterfaceOptions.PlayModeFocus.None: break;
case Options.InterfaceOptions.PlayModeFocus.GameWindow:
case Options.InterfaceOptions.PlayModeFocus.GameWindowThenRestoreEditor:
gameWin.FocusGameViewport();
break;
@@ -320,6 +321,11 @@ namespace FlaxEditor.Modules
_previousWindow.Focus();
}
break;
case Options.InterfaceOptions.PlayModeFocus.GameWindowThenRestoreEditor:
var editorWin = Editor.Windows.EditWin;
if (editorWin != null && !editorWin.IsDisposing)
editorWin.Focus();
break;
}
}
+7 -2
View File
@@ -179,6 +179,11 @@ namespace FlaxEditor.Options
/// Focus the Game Window. On play mode end restore focus to the previous window.
/// </summary>
GameWindowThenRestore,
/// <summary>
/// Focus the Game Window. On play mode end restore focus to the editor window.
/// </summary>
GameWindowThenRestoreEditor
}
/// <summary>
@@ -520,9 +525,9 @@ namespace FlaxEditor.Options
/// <summary>
/// Gets or sets a value indicating what panel should be focused when play mode start.
/// </summary>
[DefaultValue(PlayModeFocus.GameWindow)]
[DefaultValue(PlayModeFocus.GameWindowThenRestoreEditor)]
[EditorDisplay("Play In-Editor", "Focus On Play"), EditorOrder(500), Tooltip("Set what panel to focus on play mode start.")]
public PlayModeFocus FocusOnPlayMode { get; set; } = PlayModeFocus.GameWindow;
public PlayModeFocus FocusOnPlayMode { get; set; } = PlayModeFocus.GameWindowThenRestoreEditor;
/// <summary>
/// Gets or sets a value indicating what action should be taken upon pressing the play button.
+9 -3
View File
@@ -147,21 +147,27 @@ namespace FlaxEditor.Windows
new PlayModeFocusOptions
{
Name = "None",
Tooltip = "Don't change focus.",
Tooltip = "Don't change window focus when entering play mode.",
FocusOption = InterfaceOptions.PlayModeFocus.None,
},
new PlayModeFocusOptions
{
Name = "Game Window",
Tooltip = "Focus the Game Window.",
Tooltip = "Focus the Game Window when entering play mode.",
FocusOption = InterfaceOptions.PlayModeFocus.GameWindow,
},
new PlayModeFocusOptions
{
Name = "Game Window Then Restore",
Tooltip = "Focus the Game Window. On play mode end restore focus to the previous window.",
Tooltip = "Focus the Game Window when entering play mode. Restore focus to the previous window when exiting play mode.",
FocusOption = InterfaceOptions.PlayModeFocus.GameWindowThenRestore,
},
new PlayModeFocusOptions
{
Name = "Game Window Then Restore Editor",
Tooltip = "Focus the Game Window when entering play mode and then restore the focus to the editor window when exiting play mode.",
FocusOption = InterfaceOptions.PlayModeFocus.GameWindowThenRestoreEditor
}
};
/// <summary>