Disable add script item if it is not being added to a required actor.

This commit is contained in:
Chandler Cox
2024-10-22 14:56:22 -05:00
parent f62c77c35c
commit 1d631e91ce

View File

@@ -95,7 +95,21 @@ namespace FlaxEditor.CustomEditors.Dedicated
var cm = new ItemsListContextMenu(180);
for (int i = 0; i < scripts.Count; i++)
{
cm.AddItem(new TypeSearchPopup.TypeItemView(scripts[i]));
var script = scripts[i];
var item = new TypeSearchPopup.TypeItemView(script);
if (script.GetAttributes(false).FirstOrDefault(x => x is RequireActorAttribute) is RequireActorAttribute requireActor)
{
var actors = ScriptsEditor.ParentEditor.Values;
foreach (var a in actors)
{
if (a.GetType() != requireActor.RequiredType)
{
item.Enabled = false;
break;
}
}
}
cm.AddItem(item);
}
cm.TextChanged += text =>
{