diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index 3c7583b0e..75a3723cf 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -27,6 +27,7 @@ namespace FlaxEditor.Windows private Panel _sceneTreePanel; private bool _isUpdatingSelection; private bool _isMouseDown; + private bool _blockSceneTreeScroll = false; private DragAssets _dragAssets; private DragActorType _dragActorType; @@ -111,6 +112,34 @@ namespace FlaxEditor.Windows InputActions.Add(options => options.LockFocusSelection, () => Editor.Windows.EditWin.Viewport.LockFocusSelection()); InputActions.Add(options => options.Rename, RenameSelection); } + + /// + public override void OnPlayBeginning() + { + base.OnPlayBeginning(); + _blockSceneTreeScroll = true; + } + + /// + public override void OnPlayBegin() + { + base.OnPlayBegin(); + _blockSceneTreeScroll = false; + } + + /// + public override void OnPlayEnding() + { + base.OnPlayEnding(); + _blockSceneTreeScroll = true; + } + + /// + public override void OnPlayEnd() + { + base.OnPlayEnd(); + _blockSceneTreeScroll = true; + } /// /// Enables or disables vertical and horizontal scrolling on the scene tree panel. @@ -270,7 +299,7 @@ namespace FlaxEditor.Windows _tree.Select(nodes); // For single node selected scroll view so user can see it - if (nodes.Count == 1) + if (nodes.Count == 1 && !_blockSceneTreeScroll) { nodes[0].ExpandAllParents(true); _sceneTreePanel.ScrollViewTo(nodes[0]); @@ -280,6 +309,12 @@ namespace FlaxEditor.Windows _isUpdatingSelection = false; } + /// + public override void OnEditorStateChanged() + { + _blockSceneTreeScroll = Editor.StateMachine.ReloadingScriptsState.IsActive; + } + private bool ValidateDragAsset(AssetItem assetItem) { if (assetItem.IsOfType())