diff --git a/Source/Editor/Windows/ToolboxWindow.cs b/Source/Editor/Windows/ToolboxWindow.cs index aec2e6dea..b522cbb2f 100644 --- a/Source/Editor/Windows/ToolboxWindow.cs +++ b/Source/Editor/Windows/ToolboxWindow.cs @@ -219,12 +219,12 @@ namespace FlaxEditor.Windows { if (child is Tab tab) { - if (tab.Text == groupName) + if (tab.Text == groupName.Trim()) { var tree = tab.GetChild().GetChild(); if (tree != null) { - tree.AddChild(CreateActorItem(Utilities.Utils.GetPropertyNameUI(actorType.Name), actorType)); + tree.AddChild(string.IsNullOrEmpty(attribute.Name) ? CreateActorItem(Utilities.Utils.GetPropertyNameUI(actorType.Name), actorType) : CreateActorItem(attribute.Name, actorType)); tree.SortChildren(); } actorTabExists = true; @@ -235,8 +235,8 @@ namespace FlaxEditor.Windows if (actorTabExists) continue; - var group = CreateGroupWithList(actorGroups, groupName); - group.AddChild(CreateActorItem(Utilities.Utils.GetPropertyNameUI(actorType.Name), actorType)); + var group = CreateGroupWithList(actorGroups, groupName.Trim()); + group.AddChild(string.IsNullOrEmpty(attribute.Name) ? CreateActorItem(Utilities.Utils.GetPropertyNameUI(actorType.Name), actorType) : CreateActorItem(attribute.Name, actorType)); group.SortChildren(); } } @@ -253,7 +253,17 @@ namespace FlaxEditor.Windows foreach (var actorType in Editor.CodeEditing.Actors.Get()) { - var text = actorType.Name; + ActorToolboxAttribute attribute = null; + foreach (var e in actorType.GetAttributes(true)) + { + if (e is ActorToolboxAttribute actorToolboxAttribute) + { + attribute = actorToolboxAttribute; + break; + } + } + + var text = (attribute == null) ? actorType.Name : string.IsNullOrEmpty(attribute.Name) ? actorType.Name : attribute.Name; if (!QueryFilterHelper.Match(filterText, text, out QueryFilterHelper.Range[] ranges)) continue; diff --git a/Source/Engine/Scripting/Attributes/Editor/ActorToolbox.cs b/Source/Engine/Scripting/Attributes/Editor/ActorToolbox.cs index 4b3fc6558..c62b366bc 100644 --- a/Source/Engine/Scripting/Attributes/Editor/ActorToolbox.cs +++ b/Source/Engine/Scripting/Attributes/Editor/ActorToolbox.cs @@ -13,6 +13,11 @@ namespace FlaxEngine /// The path to be used in the tool box /// public string Group; + + /// + /// The name to be used for the actor in the tool box. Will default to actor name if now used. + /// + public string Name; /// /// Initializes a new instance of the class. @@ -22,5 +27,16 @@ namespace FlaxEngine { Group = group; } + + /// + /// Initializes a new instance of the class. + /// + /// The group used to creat the tab + /// The name to use rather than default + public ActorToolboxAttribute(string group, string name) + : this(group) + { + Name = name; + } } }