From 56a33e4c98f5a81770f298609af1507f19a24430 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 7 Mar 2024 20:23:00 +0100 Subject: [PATCH] Fix bug in actors duplicate action due to incorrect actors list setup #2309 --- Source/Editor/SceneGraph/SceneGraphTools.cs | 26 ++++++--------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/Source/Editor/SceneGraph/SceneGraphTools.cs b/Source/Editor/SceneGraph/SceneGraphTools.cs index 056373ae2..57b3a653b 100644 --- a/Source/Editor/SceneGraph/SceneGraphTools.cs +++ b/Source/Editor/SceneGraph/SceneGraphTools.cs @@ -92,11 +92,12 @@ namespace FlaxEditor.SceneGraph private static void FillTree(SceneGraphNode node, List result) { - result.AddRange(node.ChildNodes); - for (int i = 0; i < node.ChildNodes.Count; i++) - { - FillTree(node.ChildNodes[i], result); - } + if (result.Contains(node)) + return; + result.Add(node); + var children = node.ChildNodes; + for (int i = 0; i < children.Count; i++) + FillTree(children[i], result); } /// @@ -109,21 +110,9 @@ namespace FlaxEditor.SceneGraph { if (nodes == null || result == null) throw new ArgumentNullException(); - result.Clear(); - for (var i = 0; i < nodes.Count; i++) - { - var target = nodes[i]; - - // Check if has been already added - if (result.Contains(target)) - continue; - - // Add whole child tree to the results - result.Add(target); - FillTree(target, result); - } + FillTree(nodes[i], result); } /// @@ -150,7 +139,6 @@ namespace FlaxEditor.SceneGraph if (node == null || result == null) throw new ArgumentNullException(); result.Clear(); - result.Add(node); FillTree(node, result); } }