Simplify code in #2202 for script type searching

This commit is contained in:
Wojtek Figat
2024-02-06 11:09:08 +01:00
parent 741682b5e7
commit b2d0afd4ef
7 changed files with 31 additions and 43 deletions

View File

@@ -274,13 +274,10 @@ namespace FlaxEditor.Windows
{
return true;
}
private static bool ValidateDragScriptItem(ScriptItem script)
{
var actors = Editor.Instance.CodeEditing.Actors.Get();
if (actors.Any(x => x.ContentItem == script))
return true;
return false;
return Editor.Instance.CodeEditing.Actors.Get(script) != ScriptType.Null;
}
/// <inheritdoc />
@@ -468,12 +465,9 @@ namespace FlaxEditor.Windows
for (int i = 0; i < _dragScriptItems.Objects.Count; i++)
{
var item = _dragScriptItems.Objects[i];
// Find actors with the same content item and spawn them.
foreach (var actorType in Editor.Instance.CodeEditing.Actors.Get())
var actorType = Editor.Instance.CodeEditing.Actors.Get(item);
if (actorType != ScriptType.Null)
{
if (actorType.ContentItem != item)
continue;
var actor = actorType.CreateInstance() as Actor;
if (actor == null)
{