Fix prefab window performance with large hierarchies

This commit is contained in:
Wojtek Figat
2023-12-05 23:44:45 +01:00
parent 63ddf53ad3
commit 5575917c4b
3 changed files with 20 additions and 9 deletions

View File

@@ -85,12 +85,20 @@ namespace FlaxEditor.SceneGraph.GUI
{ {
if (Parent is ActorTreeNode parent) 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) if (children[i] is ActorTreeNode child && child.Actor)
child._orderInParent = child.Actor.OrderInParent; {
var orderInParent = child.Actor.OrderInParent;
anyChanged |= child._orderInParent != orderInParent;
if (anyChanged)
child._orderInParent = orderInParent;
}
} }
parent.SortChildren(); if (anyChanged)
parent.SortChildren();
} }
else if (Actor) else if (Actor)
{ {

View File

@@ -428,11 +428,9 @@ namespace FlaxEditor.Windows.Assets
private void Update(ActorNode actorNode) private void Update(ActorNode actorNode)
{ {
if (actorNode.Actor) actorNode.TreeNode.UpdateText();
{ if (actorNode.TreeNode.IsCollapsed)
actorNode.TreeNode.UpdateText(); return;
actorNode.TreeNode.OnOrderInParentChanged();
}
for (int i = 0; i < actorNode.ChildNodes.Count; i++) for (int i = 0; i < actorNode.ChildNodes.Count; i++)
{ {

View File

@@ -440,6 +440,7 @@ namespace FlaxEditor.Windows.Assets
{ {
try try
{ {
FlaxEngine.Profiler.BeginEvent("PrefabWindow.Update");
if (Graph.Main != null) if (Graph.Main != null)
{ {
// Due to fact that actors in prefab editor are only created but not added to gameplay // 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); Graph.Root.TreeNode.ExpandAll(true);
} }
} }
finally
{
FlaxEngine.Profiler.EndEvent();
}
// Auto fit // Auto fit
if (_focusCamera && _viewport.Task.FrameCount > 1) if (_focusCamera && _viewport.Task.FrameCount > 1)