diff --git a/Source/Editor/Modules/ContentEditingModule.cs b/Source/Editor/Modules/ContentEditingModule.cs index 563143fc5..f9d6e825c 100644 --- a/Source/Editor/Modules/ContentEditingModule.cs +++ b/Source/Editor/Modules/ContentEditingModule.cs @@ -57,31 +57,7 @@ namespace FlaxEditor.Modules } if (window != null && !disableAutoShow) { - var newLocation = (DockState)Editor.Options.Options.Interface.NewWindowLocation; - if (newLocation == DockState.Float) - { - // Check if there is a floating window that has the same size - Vector2 defaultSize = window.DefaultSize; - for (var i = 0; i < Editor.UI.MasterPanel.FloatingPanels.Count; i++) - { - var win = Editor.UI.MasterPanel.FloatingPanels[i]; - - // Check if size is similar - if (Vector2.Abs(win.Size - defaultSize).LengthSquared < 100) - { - // Dock - window.Show(DockState.DockFill, win); - window.Focus(); - return window; - } - } - - window.ShowFloating(defaultSize); - } - else - { - window.Show(newLocation); - } + Editor.Windows.Open(window); } return window; diff --git a/Source/Editor/Modules/WindowsModule.cs b/Source/Editor/Modules/WindowsModule.cs index e1d1a6753..80714924d 100644 --- a/Source/Editor/Modules/WindowsModule.cs +++ b/Source/Editor/Modules/WindowsModule.cs @@ -665,6 +665,36 @@ namespace FlaxEditor.Modules } } + /// + /// Opens the specified editor window (shows it with editor options handling for new windows). + /// + /// The window. + public void Open(EditorWindow window) + { + var newLocation = (DockState)Editor.Options.Options.Interface.NewWindowLocation; + if (newLocation == DockState.Float) + { + // Check if there is a floating window that has the same size + Vector2 defaultSize = window.DefaultSize; + for (var i = 0; i < Editor.UI.MasterPanel.FloatingPanels.Count; i++) + { + var win = Editor.UI.MasterPanel.FloatingPanels[i]; + if (Vector2.Abs(win.Size - defaultSize).LengthSquared < 100) + { + window.Show(DockState.DockFill, win); + window.Focus(); + return; + } + } + + window.ShowFloating(defaultSize); + } + else + { + window.Show(newLocation); + } + } + /// /// Gets that is represented by the given serialized typename. Used to restore workspace layout. ///