diff --git a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs index f64e46385..14f11ceef 100644 --- a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs +++ b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs @@ -85,12 +85,20 @@ namespace FlaxEditor.SceneGraph.GUI { if (Parent is ActorTreeNode parent) { - for (int i = 0; i < parent.ChildrenCount; i++) + var anyChanged = false; + var children = parent.Children; + for (int i = 0; i < children.Count; i++) { - if (parent.Children[i] is ActorTreeNode child && child.Actor) - child._orderInParent = child.Actor.OrderInParent; + if (children[i] is ActorTreeNode child && child.Actor) + { + var orderInParent = child.Actor.OrderInParent; + anyChanged |= child._orderInParent != orderInParent; + if (anyChanged) + child._orderInParent = orderInParent; + } } - parent.SortChildren(); + if (anyChanged) + parent.SortChildren(); } else if (Actor) { diff --git a/Source/Editor/Windows/Assets/PrefabWindow.Hierarchy.cs b/Source/Editor/Windows/Assets/PrefabWindow.Hierarchy.cs index a8d9ae1be..be8f09f3a 100644 --- a/Source/Editor/Windows/Assets/PrefabWindow.Hierarchy.cs +++ b/Source/Editor/Windows/Assets/PrefabWindow.Hierarchy.cs @@ -428,11 +428,9 @@ namespace FlaxEditor.Windows.Assets private void Update(ActorNode actorNode) { - if (actorNode.Actor) - { - actorNode.TreeNode.UpdateText(); - actorNode.TreeNode.OnOrderInParentChanged(); - } + actorNode.TreeNode.UpdateText(); + if (actorNode.TreeNode.IsCollapsed) + return; for (int i = 0; i < actorNode.ChildNodes.Count; i++) { diff --git a/Source/Editor/Windows/Assets/PrefabWindow.cs b/Source/Editor/Windows/Assets/PrefabWindow.cs index f50a832a1..025760b1e 100644 --- a/Source/Editor/Windows/Assets/PrefabWindow.cs +++ b/Source/Editor/Windows/Assets/PrefabWindow.cs @@ -440,6 +440,7 @@ namespace FlaxEditor.Windows.Assets { try { + FlaxEngine.Profiler.BeginEvent("PrefabWindow.Update"); if (Graph.Main != null) { // Due to fact that actors in prefab editor are only created but not added to gameplay @@ -468,6 +469,10 @@ namespace FlaxEditor.Windows.Assets Graph.Root.TreeNode.ExpandAll(true); } } + finally + { + FlaxEngine.Profiler.EndEvent(); + } // Auto fit if (_focusCamera && _viewport.Task.FrameCount > 1)