From 53e3cee1967ddbeb7b7fa8f94b7d60202da15a11 Mon Sep 17 00:00:00 2001 From: Zode Date: Sat, 7 Jun 2025 17:15:54 +0300 Subject: [PATCH 01/13] Scroll selected to view when emptying out search box --- Source/Editor/Windows/SceneTreeWindow.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index 705976e6e..78aa123ea 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -144,6 +144,7 @@ namespace FlaxEditor.Windows _tree.UnlockChildrenRecursive(); PerformLayout(); PerformLayout(); + ScrollToSelectedNode(); } private void Spawn(Type type) From 85fd1389dbb7698ec5defb476c4273fe417f8f35 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Sat, 7 Jun 2025 18:17:40 +0200 Subject: [PATCH 02/13] clear content panel search when selecting asset picker asset --- Source/Editor/GUI/AssetPicker.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Editor/GUI/AssetPicker.cs b/Source/Editor/GUI/AssetPicker.cs index b3690e754..bf04aa068 100644 --- a/Source/Editor/GUI/AssetPicker.cs +++ b/Source/Editor/GUI/AssetPicker.cs @@ -299,6 +299,7 @@ namespace FlaxEditor.GUI { // Select asset Editor.Instance.Windows.ContentWin.Select(Validator.SelectedItem); + Editor.Instance.Windows.ContentWin.ClearItemsSearch(); } } else if (Button1Rect.Contains(location)) @@ -312,6 +313,7 @@ namespace FlaxEditor.GUI { // Select asset Editor.Instance.Windows.ContentWin.Select(Validator.SelectedItem); + Editor.Instance.Windows.ContentWin.ClearItemsSearch(); } else if (Button3Rect.Contains(location)) { From 74000fa76622597b4183bd50116c6b848e2d7363 Mon Sep 17 00:00:00 2001 From: Zode Date: Sat, 7 Jun 2025 22:53:07 +0300 Subject: [PATCH 03/13] Expand tree if necessary, so the selected node will be shown --- Source/Editor/Windows/SceneTreeWindow.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index 78aa123ea..8f06008a5 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -142,9 +142,21 @@ namespace FlaxEditor.Windows root.TreeNode.UpdateFilter(query); _tree.UnlockChildrenRecursive(); + + var nodeSelection = _tree.Selection; + if(nodeSelection.Count != 0) + { + var node = nodeSelection[nodeSelection.Count - 1]; + node.Expand(true); + } + PerformLayout(); PerformLayout(); - ScrollToSelectedNode(); + + if(nodeSelection.Count != 0) + { + ScrollToSelectedNode(); + } } private void Spawn(Type type) From 568719b615db6e7a6998c73ac18805328b0be215 Mon Sep 17 00:00:00 2001 From: Zode Date: Sat, 7 Jun 2025 23:21:41 +0300 Subject: [PATCH 04/13] Fix scroll issue caused by tree's defered layout update --- Source/Editor/Windows/SceneTreeWindow.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index 8f06008a5..20cfa3584 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -34,6 +34,7 @@ namespace FlaxEditor.Windows private DragScriptItems _dragScriptItems; private DragHandlers _dragHandlers; private bool _isDropping = false; + private bool _forceScrollNodeToView = false; /// /// Scene tree panel. @@ -148,13 +149,21 @@ namespace FlaxEditor.Windows { var node = nodeSelection[nodeSelection.Count - 1]; node.Expand(true); + _forceScrollNodeToView = true; } PerformLayout(); PerformLayout(); + } - if(nodeSelection.Count != 0) + /// + public override void Update(float deltaTime) + { + base.Update(deltaTime); + + if(_tree.Selection.Count != 0 && _forceScrollNodeToView) { + _forceScrollNodeToView = false; ScrollToSelectedNode(); } } From 1fa83639c2f1e729c918b4ccd1a181e5f26b0201 Mon Sep 17 00:00:00 2001 From: Zode Date: Sun, 8 Jun 2025 00:38:59 +0300 Subject: [PATCH 05/13] Fix update order inconsistencies between machines by exposing an action for when defered layout happens. --- Source/Editor/GUI/Tree/Tree.cs | 6 ++++++ Source/Editor/Windows/SceneTreeWindow.cs | 19 +++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Source/Editor/GUI/Tree/Tree.cs b/Source/Editor/GUI/Tree/Tree.cs index e36f0ccd5..3e1453f03 100644 --- a/Source/Editor/GUI/Tree/Tree.cs +++ b/Source/Editor/GUI/Tree/Tree.cs @@ -73,6 +73,11 @@ namespace FlaxEditor.GUI.Tree /// public bool DrawRootTreeLine = true; + /// + /// Occurs when the defered layouting happens + /// + public event Action OnDeferedLayout; + /// /// Gets or sets the margin for the child tree nodes. /// @@ -375,6 +380,7 @@ namespace FlaxEditor.GUI.Tree if (_deferLayoutUpdate) { base.PerformLayout(); + OnDeferedLayout?.Invoke(); _deferLayoutUpdate = false; } diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index 20cfa3584..9175a660b 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -92,6 +92,13 @@ namespace FlaxEditor.Windows _tree.SelectedChanged += Tree_OnSelectedChanged; _tree.RightClick += OnTreeRightClick; _tree.Parent = _sceneTreePanel; + _tree.OnDeferedLayout += () => { + if(_tree.Selection.Count != 0 && _forceScrollNodeToView) + { + _forceScrollNodeToView = false; + ScrollToSelectedNode(); + } + }; headerPanel.Parent = this; // Setup input actions @@ -156,18 +163,6 @@ namespace FlaxEditor.Windows PerformLayout(); } - /// - public override void Update(float deltaTime) - { - base.Update(deltaTime); - - if(_tree.Selection.Count != 0 && _forceScrollNodeToView) - { - _forceScrollNodeToView = false; - ScrollToSelectedNode(); - } - } - private void Spawn(Type type) { // Create actor From ecd5559aada8b76b5508254232ee2f5ee36f82aa Mon Sep 17 00:00:00 2001 From: Zode Date: Sun, 8 Jun 2025 00:41:02 +0300 Subject: [PATCH 06/13] Clean up a bit code after moving it around. --- Source/Editor/Windows/SceneTreeWindow.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index 9175a660b..620300485 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -93,12 +93,13 @@ namespace FlaxEditor.Windows _tree.RightClick += OnTreeRightClick; _tree.Parent = _sceneTreePanel; _tree.OnDeferedLayout += () => { - if(_tree.Selection.Count != 0 && _forceScrollNodeToView) + if(_forceScrollNodeToView) { _forceScrollNodeToView = false; ScrollToSelectedNode(); } }; + headerPanel.Parent = this; // Setup input actions From 112e7284655eff9d2424186809b2f6f396bf6fb5 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Mon, 9 Jun 2025 13:56:41 +0200 Subject: [PATCH 07/13] fix scroll to node on selection in prefab editor --- Source/Editor/Windows/Assets/PrefabWindow.Selection.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/Editor/Windows/Assets/PrefabWindow.Selection.cs b/Source/Editor/Windows/Assets/PrefabWindow.Selection.cs index 03e2a9652..6208aa7a1 100644 --- a/Source/Editor/Windows/Assets/PrefabWindow.Selection.cs +++ b/Source/Editor/Windows/Assets/PrefabWindow.Selection.cs @@ -97,10 +97,7 @@ namespace FlaxEditor.Windows.Assets // For single node selected scroll view so user can see it if (nodes.Count == 1) - { - nodes[0].ExpandAllParents(true); - ScrollViewTo(nodes[0]); - } + ScrollToSelectedNode(); } // Update properties editor From 2109a2d26153d163e3da5d5ed0324ec7b58e8489 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Mon, 9 Jun 2025 18:40:12 +0200 Subject: [PATCH 08/13] update content finder popup to wrap on keyboard navigation - Fixes auto scroll - Make it wrap - Add pressing backspace to focus search bar and select all text --- Source/Editor/Windows/Search/ContentFinder.cs | 47 +++++++------------ 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/Source/Editor/Windows/Search/ContentFinder.cs b/Source/Editor/Windows/Search/ContentFinder.cs index e4227e5c4..12b479aea 100644 --- a/Source/Editor/Windows/Search/ContentFinder.cs +++ b/Source/Editor/Windows/Search/ContentFinder.cs @@ -180,39 +180,17 @@ namespace FlaxEditor.Windows.Search switch (key) { case KeyboardKeys.ArrowDown: - { - if (_matchedItems.Count == 0) - return true; - int currentPos; - if (_selectedItem != null) - { - currentPos = _matchedItems.IndexOf(_selectedItem) + 1; - if (currentPos >= _matchedItems.Count) - currentPos--; - } - else - { - currentPos = 0; - } - SelectedItem = _matchedItems[currentPos]; - return true; - } case KeyboardKeys.ArrowUp: { if (_matchedItems.Count == 0) return true; - int currentPos; - if (_selectedItem != null) - { - currentPos = _matchedItems.IndexOf(_selectedItem) - 1; - if (currentPos < 0) - currentPos = 0; - } - else - { - currentPos = 0; - } - SelectedItem = _matchedItems[currentPos]; + + var focusedIndex = _matchedItems.IndexOf(_selectedItem); + int delta = key == KeyboardKeys.ArrowDown ? -1 : 1; + int nextIndex = Mathf.Wrap(focusedIndex - delta, 0, _matchedItems.Count - 1); + var nextItem = _matchedItems[nextIndex]; + + SelectedItem = nextItem; return true; } case KeyboardKeys.Return: @@ -234,6 +212,17 @@ namespace FlaxEditor.Windows.Search Hide(); return true; } + case KeyboardKeys.Backspace: + { + // Alow the user to quickly focus the searchbar + if (_searchBox != null && !_searchBox.IsFocused) + { + _searchBox.Focus(); + _searchBox.SelectAll(); + return true; + } + break; + } } return base.OnKeyDown(key); From 793bc33b2fa272cf9717c336ef62449515ca1da4 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Mon, 9 Jun 2025 18:40:33 +0200 Subject: [PATCH 09/13] fix right clicking on item reset search and scroll --- Source/Editor/Windows/Search/ContentFinder.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Editor/Windows/Search/ContentFinder.cs b/Source/Editor/Windows/Search/ContentFinder.cs index 12b479aea..9118739b8 100644 --- a/Source/Editor/Windows/Search/ContentFinder.cs +++ b/Source/Editor/Windows/Search/ContentFinder.cs @@ -42,6 +42,7 @@ namespace FlaxEditor.Windows.Search if (value == _selectedItem || (value != null && !_matchedItems.Contains(value))) return; + // Restore the previous selected item to the non-selected color if (_selectedItem != null) { _selectedItem.BackgroundColor = Color.Transparent; @@ -54,6 +55,7 @@ namespace FlaxEditor.Windows.Search _selectedItem.BackgroundColor = Style.Current.BackgroundSelected; if (_matchedItems.Count > VisibleItemCount) { + _selectedItem.Focus(); _resultPanel.ScrollViewTo(_selectedItem, true); } } From 214ec9f2b1fe9de1e545c1399922e6a8245e9e88 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Thu, 12 Jun 2025 00:49:39 +0200 Subject: [PATCH 10/13] fix node delete button not checking if the user is performing certain actions on the surface before deleting node --- Source/Editor/Surface/SurfaceNode.cs | 12 +++++++----- Source/Editor/Surface/VisjectSurface.Draw.cs | 2 +- Source/Editor/Surface/VisjectSurface.Input.cs | 3 +++ Source/Editor/Surface/VisjectSurface.cs | 14 ++++++++++++-- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Source/Editor/Surface/SurfaceNode.cs b/Source/Editor/Surface/SurfaceNode.cs index 8a42a7a92..5dedd604f 100644 --- a/Source/Editor/Surface/SurfaceNode.cs +++ b/Source/Editor/Surface/SurfaceNode.cs @@ -912,7 +912,7 @@ namespace FlaxEditor.Surface /// public override bool OnTestTooltipOverControl(ref Float2 location) { - return _headerRect.Contains(ref location) && ShowTooltip; + return _headerRect.Contains(ref location) && ShowTooltip && !Surface.IsConnecting && !Surface.IsBoxSelecting; } /// @@ -1070,7 +1070,7 @@ namespace FlaxEditor.Surface // Header var headerColor = style.BackgroundHighlighted; - if (_headerRect.Contains(ref _mousePosition)) + if (_headerRect.Contains(ref _mousePosition) && !Surface.IsConnecting && !Surface.IsBoxSelecting) headerColor *= 1.07f; Render2D.FillRectangle(_headerRect, headerColor); Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center); @@ -1078,7 +1078,8 @@ namespace FlaxEditor.Surface // Close button if ((Archetype.Flags & NodeFlags.NoCloseButton) == 0 && Surface.CanEdit) { - Render2D.DrawSprite(style.Cross, _closeButtonRect, _closeButtonRect.Contains(_mousePosition) ? style.Foreground : style.ForegroundGrey); + bool highlightClose = _closeButtonRect.Contains(_mousePosition) && !Surface.IsConnecting && !Surface.IsBoxSelecting; + Render2D.DrawSprite(style.Cross, _closeButtonRect, highlightClose ? style.Foreground : style.ForegroundGrey); } // Footer @@ -1123,8 +1124,9 @@ namespace FlaxEditor.Surface if (base.OnMouseUp(location, button)) return true; - // Close - if (button == MouseButton.Left && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(ref location)) + // Close/ delete + bool canDelete = !Surface.IsConnecting && !Surface.WasBoxSelecting && !Surface.WasMovingSelection; + if (button == MouseButton.Left && canDelete && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(ref location)) { Surface.Delete(this); return true; diff --git a/Source/Editor/Surface/VisjectSurface.Draw.cs b/Source/Editor/Surface/VisjectSurface.Draw.cs index 5a63fe4de..01277d0d2 100644 --- a/Source/Editor/Surface/VisjectSurface.Draw.cs +++ b/Source/Editor/Surface/VisjectSurface.Draw.cs @@ -225,7 +225,7 @@ namespace FlaxEditor.Surface _rootControl.DrawComments(); - if (IsSelecting) + if (IsBoxSelecting) { DrawSelection(); } diff --git a/Source/Editor/Surface/VisjectSurface.Input.cs b/Source/Editor/Surface/VisjectSurface.Input.cs index a874db681..ced29d819 100644 --- a/Source/Editor/Surface/VisjectSurface.Input.cs +++ b/Source/Editor/Surface/VisjectSurface.Input.cs @@ -544,6 +544,9 @@ namespace FlaxEditor.Surface // Cache flags and state if (_leftMouseDown && button == MouseButton.Left) { + WasBoxSelecting = IsBoxSelecting; + WasMovingSelection = _isMovingSelection; + _leftMouseDown = false; EndMouseCapture(); Cursor = CursorType.Default; diff --git a/Source/Editor/Surface/VisjectSurface.cs b/Source/Editor/Surface/VisjectSurface.cs index faecebbd3..4a1bad1da 100644 --- a/Source/Editor/Surface/VisjectSurface.cs +++ b/Source/Editor/Surface/VisjectSurface.cs @@ -232,15 +232,25 @@ namespace FlaxEditor.Surface } /// - /// Gets a value indicating whether user is selecting nodes. + /// Gets a value indicating whether user is box selecting nodes. /// - public bool IsSelecting => _leftMouseDown && !_isMovingSelection && _connectionInstigator == null; + public bool IsBoxSelecting => _leftMouseDown && !_isMovingSelection && _connectionInstigator == null; + + /// + /// Gets a value indicating whether user was previously box selecting nodes. + /// + public bool WasBoxSelecting { get; private set; } /// /// Gets a value indicating whether user is moving selected nodes. /// public bool IsMovingSelection => _leftMouseDown && _isMovingSelection && _connectionInstigator == null; + /// + /// Gets a value indicating whether user was previously moving selected nodes. + /// + public bool WasMovingSelection { get; private set; } + /// /// Gets a value indicating whether user is connecting nodes. /// From ea854a0f7b6864ca4c12ffedd8b6679064433755 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 16 Jun 2025 14:41:43 +0200 Subject: [PATCH 11/13] Fix potential Grid shader accuracy issues #3229 --- Content/Shaders/Editor/Grid.flax | 4 ++-- Source/Shaders/Editor/Grid.shader | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Content/Shaders/Editor/Grid.flax b/Content/Shaders/Editor/Grid.flax index 311867604..09ecd00e6 100644 --- a/Content/Shaders/Editor/Grid.flax +++ b/Content/Shaders/Editor/Grid.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c13729c4ec2ef534271c60fee6fff2e0489bf4445fe91aa8a2bbc3d581715602 -size 4666 +oid sha256:e5671b8b77b460a17d0a3c14174994a05cf1b3d8869d10b350de4a8053419836 +size 4647 diff --git a/Source/Shaders/Editor/Grid.shader b/Source/Shaders/Editor/Grid.shader index f109ddd1a..45bb1ed90 100644 --- a/Source/Shaders/Editor/Grid.shader +++ b/Source/Shaders/Editor/Grid.shader @@ -3,7 +3,7 @@ // Ben Golus // https://bgolus.medium.com/the-best-darn-grid-shader-yet-727f9278b9d8#3e73 -#define USE_FORWARD true; +#define MIN_DERIV 0.00001f #include "./Flax/Common.hlsl" @@ -61,11 +61,6 @@ float remap(float origFrom, float origTo, float targetFrom, float targetTo, floa return lerp(targetFrom, targetTo, rel); } -float ddLength(float a) -{ - return length(float2(ddx(a), ddy(a))); -} - float GetLine(float pos, float scale, float thickness) { float lineWidth = thickness; @@ -73,7 +68,7 @@ float GetLine(float pos, float scale, float thickness) float2 uvDDXY = float2(ddx(coord), ddy(coord)); - float deriv = float(length(uvDDXY.xy)); + float deriv = max(float(length(uvDDXY.xy)), MIN_DERIV); float drawWidth = clamp(lineWidth, deriv, 0.5); float lineAA = deriv * 1.5; float gridUV = abs(coord); @@ -92,7 +87,7 @@ float GetGrid(float3 pos, float scale, float thickness) float4 uvDDXY = float4(ddx(coord), ddy(coord)); - float2 deriv = float2(length(uvDDXY.xz), length(uvDDXY.yw)); + float2 deriv = max(float2(length(uvDDXY.xz), length(uvDDXY.yw)), float2(MIN_DERIV, MIN_DERIV)); float2 drawWidth = clamp(lineWidth, deriv, 0.5); float2 lineAA = deriv * 1.5; float2 gridUV = 1.0 - abs(frac(coord) * 2.0 - 1.0); From a6a2fd2c66c919ac3ad609fbb59b88054083512f Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 16 Jun 2025 14:48:18 +0200 Subject: [PATCH 12/13] Format code #3526 --- Source/Editor/GUI/Tree/Tree.cs | 6 +++--- Source/Editor/Windows/SceneTreeWindow.cs | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Source/Editor/GUI/Tree/Tree.cs b/Source/Editor/GUI/Tree/Tree.cs index 3e1453f03..8df26c211 100644 --- a/Source/Editor/GUI/Tree/Tree.cs +++ b/Source/Editor/GUI/Tree/Tree.cs @@ -74,9 +74,9 @@ namespace FlaxEditor.GUI.Tree public bool DrawRootTreeLine = true; /// - /// Occurs when the defered layouting happens + /// Occurs when the deferred layout operation was performed. /// - public event Action OnDeferedLayout; + public event Action AfterDeferredLayout; /// /// Gets or sets the margin for the child tree nodes. @@ -380,7 +380,7 @@ namespace FlaxEditor.GUI.Tree if (_deferLayoutUpdate) { base.PerformLayout(); - OnDeferedLayout?.Invoke(); + AfterDeferredLayout?.Invoke(); _deferLayoutUpdate = false; } diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index 620300485..3c7583b0e 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -92,14 +92,15 @@ namespace FlaxEditor.Windows _tree.SelectedChanged += Tree_OnSelectedChanged; _tree.RightClick += OnTreeRightClick; _tree.Parent = _sceneTreePanel; - _tree.OnDeferedLayout += () => { - if(_forceScrollNodeToView) + _tree.AfterDeferredLayout += () => + { + if (_forceScrollNodeToView) { _forceScrollNodeToView = false; ScrollToSelectedNode(); } }; - + headerPanel.Parent = this; // Setup input actions @@ -151,9 +152,10 @@ namespace FlaxEditor.Windows root.TreeNode.UpdateFilter(query); _tree.UnlockChildrenRecursive(); - + + // When keep the selected nodes in a view var nodeSelection = _tree.Selection; - if(nodeSelection.Count != 0) + if (nodeSelection.Count != 0) { var node = nodeSelection[nodeSelection.Count - 1]; node.Expand(true); From 90b6293bc279ef4a816b948a3da6351bead6a234 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 16 Jun 2025 14:56:35 +0200 Subject: [PATCH 13/13] Add `OnPlayEnding` to editor modules and windows #3514 --- Source/Editor/Editor.cs | 2 ++ Source/Editor/Modules/EditorModule.cs | 7 +++++++ Source/Editor/Modules/WindowsModule.cs | 7 +++++++ Source/Editor/Windows/EditorWindow.cs | 7 +++++++ 4 files changed, 23 insertions(+) diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs index c6ead7a76..8c3256eb9 100644 --- a/Source/Editor/Editor.cs +++ b/Source/Editor/Editor.cs @@ -670,6 +670,8 @@ namespace FlaxEditor { FlaxEngine.Networking.NetworkManager.Stop(); // Shutdown any multiplayer from playmode PlayModeEnding?.Invoke(); + for (int i = 0; i < _modules.Count; i++) + _modules[i].OnPlayEnding(); } internal void OnPlayEnd() diff --git a/Source/Editor/Modules/EditorModule.cs b/Source/Editor/Modules/EditorModule.cs index 8285088fa..410453302 100644 --- a/Source/Editor/Modules/EditorModule.cs +++ b/Source/Editor/Modules/EditorModule.cs @@ -76,6 +76,13 @@ namespace FlaxEditor.Modules { } + /// + /// Called when Editor will leave the play mode. + /// + public virtual void OnPlayEnding() + { + } + /// /// Called when Editor leaves the play mode. /// diff --git a/Source/Editor/Modules/WindowsModule.cs b/Source/Editor/Modules/WindowsModule.cs index 289c5d7e8..5c9c613d2 100644 --- a/Source/Editor/Modules/WindowsModule.cs +++ b/Source/Editor/Modules/WindowsModule.cs @@ -1223,6 +1223,13 @@ namespace FlaxEditor.Modules Windows[i].OnPlayBegin(); } + /// + public override void OnPlayEnding() + { + for (int i = 0; i < Windows.Count; i++) + Windows[i].OnPlayEnding(); + } + /// public override void OnPlayEnd() { diff --git a/Source/Editor/Windows/EditorWindow.cs b/Source/Editor/Windows/EditorWindow.cs index f61f5cce6..6d01432ba 100644 --- a/Source/Editor/Windows/EditorWindow.cs +++ b/Source/Editor/Windows/EditorWindow.cs @@ -219,6 +219,13 @@ namespace FlaxEditor.Windows { } + /// + /// Called when Editor will leave the play mode. + /// + public virtual void OnPlayEnding() + { + } + /// /// Called when Editor leaves the play mode. ///