Unify all GetActorsTree usages in Editor

This commit is contained in:
Wojtek Figat
2023-06-12 18:25:44 +02:00
parent 5f8e5d44dc
commit 37bf4bb34f
4 changed files with 13 additions and 33 deletions

View File

@@ -27,16 +27,6 @@ namespace FlaxEditor.CustomEditors.Editors
element.ComboBox.SelectedIndexChanged += OnSelectedIndexChanged;
}
private void GetActorsTree(List<Actor> list, Actor a)
{
list.Add(a);
int cnt = a.ChildrenCount;
for (int i = 0; i < cnt; i++)
{
GetActorsTree(list, a.GetChild(i));
}
}
private void OnSelectedIndexChanged(ComboBox comboBox)
{
int value = comboBox.SelectedIndex;
@@ -60,7 +50,7 @@ namespace FlaxEditor.CustomEditors.Editors
// Note: this possibly breaks the design a little bit
// But it's the easiest way to set value for selected actor and its children with one undo action
List<Actor> actors = new List<Actor>(32);
GetActorsTree(actors, actor);
Utilities.Utils.GetActorsTree(actors, actor);
if (Presenter.Undo != null)
{
using (new UndoMultiBlock(Presenter.Undo, actors.ToArray(), "Change layer"))

View File

@@ -10,16 +10,6 @@ namespace FlaxEditor.CustomEditors.Editors
/// </summary>
public sealed class ActorStaticFlagsEditor : EnumEditor
{
private void GetActorsTree(List<Actor> list, Actor a)
{
list.Add(a);
int cnt = a.ChildrenCount;
for (int i = 0; i < cnt; i++)
{
GetActorsTree(list, a.GetChild(i));
}
}
/// <inheritdoc />
protected override void OnValueChanged()
{
@@ -40,7 +30,7 @@ namespace FlaxEditor.CustomEditors.Editors
// Note: this possibly breaks the design a little bit
// But it's the easiest way to set value for selected actor and its children with one undo action
List<Actor> actors = new List<Actor>(32);
GetActorsTree(actors, actor);
Utilities.Utils.GetActorsTree(actors, actor);
if (Presenter.Undo != null && Presenter.Undo.Enabled)
{
using (new UndoMultiBlock(Presenter.Undo, actors.ToArray(), "Change static flags"))

View File

@@ -629,7 +629,7 @@ namespace FlaxEditor.SceneGraph.GUI
{
// Set all Actors static flags to match parents
List<Actor> childActors = new List<Actor>();
GetActorsTree(childActors, actor);
Utilities.Utils.GetActorsTree(childActors, actor);
foreach (var child in childActors)
{
child.StaticFlags = spawnParent.StaticFlags;
@@ -679,16 +679,6 @@ namespace FlaxEditor.SceneGraph.GUI
return result;
}
private void GetActorsTree(List<Actor> list, Actor a)
{
list.Add(a);
int cnt = a.ChildrenCount;
for (int i = 0; i < cnt; i++)
{
GetActorsTree(list, a.GetChild(i));
}
}
private bool ValidateDragActor(ActorNode actorNode)
{

View File

@@ -102,6 +102,16 @@ namespace FlaxEditor.Utilities
return str;
}
internal static void GetActorsTree(List<Actor> list, Actor a)
{
list.Add(a);
int cnt = a.ChildrenCount;
for (int i = 0; i < cnt; i++)
{
GetActorsTree(list, a.GetChild(i));
}
}
/// <summary>
/// The colors for the keyframes used by the curve editor.
/// </summary>