Added the ability to specify the name of the actor in the toolbox, works in searching as well.
This commit is contained in:
@@ -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<Panel>().GetChild<Tree>();
|
||||
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;
|
||||
|
||||
@@ -13,6 +13,11 @@ namespace FlaxEngine
|
||||
/// The path to be used in the tool box
|
||||
/// </summary>
|
||||
public string Group;
|
||||
|
||||
/// <summary>
|
||||
/// The name to be used for the actor in the tool box. Will default to actor name if now used.
|
||||
/// </summary>
|
||||
public string Name;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ActorToolboxAttribute"/> class.
|
||||
@@ -22,5 +27,16 @@ namespace FlaxEngine
|
||||
{
|
||||
Group = group;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ActorToolboxAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="group">The group used to creat the tab</param>
|
||||
/// <param name="name">The name to use rather than default</param>
|
||||
public ActorToolboxAttribute(string group, string name)
|
||||
: this(group)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user