diff --git a/Source/Editor/GUI/Tree/Tree.cs b/Source/Editor/GUI/Tree/Tree.cs index 02a9f47cb..e6add00cc 100644 --- a/Source/Editor/GUI/Tree/Tree.cs +++ b/Source/Editor/GUI/Tree/Tree.cs @@ -40,6 +40,7 @@ namespace FlaxEditor.GUI.Tree private readonly bool _supportMultiSelect; private Margin _margin; private bool _autoSize = true; + private bool _deferLayoutUpdate = false; /// /// The TreeNode that is being dragged over. This could have a value when not dragging. @@ -353,9 +354,25 @@ namespace FlaxEditor.GUI.Tree BulkSelectUpdateExpanded(false); } + /// + public override void PerformLayout(bool force = false) + { + if (_isLayoutLocked && !force) + return; + + // In case the tree was fully expanded or collapsed along its children, avoid calculating the layout multiple times for each child + _deferLayoutUpdate = true; + } + /// public override void Update(float deltaTime) { + if (_deferLayoutUpdate) + { + base.PerformLayout(); + _deferLayoutUpdate = false; + } + var node = SelectedNode; // Check if has focus and if any node is focused and it isn't a root