// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. using System; using FlaxEngine; using FlaxEngine.GUI; using FlaxEngine.Utilities; namespace FlaxEditor.GUI { /// /// Popup that shows the list of scripts to pick. Supports searching and basic type filtering. /// /// public class ScriptSearchPopup : ItemsListContextMenu { /// /// The script item. /// /// public class ScriptItemView : Item { private Script _script; /// /// Gets the script. /// public Script Script => _script; /// /// Initializes a new instance of the class. /// /// The script. public ScriptItemView(Script script) { _script = script; var type = TypeUtils.GetObjectType(script); Name = script.Actor ? $"{type.Name} ({script.Actor.Name})" : type.Name; var str = type.Name; var o = script.Parent; while (o) { str = o.Name + " -> " + str; o = o.Parent; } TooltipText = str; } /// public override void OnDestroy() { _script = null; base.OnDestroy(); } } /// /// Validates if the given script item can be used to pick it. /// /// The script. /// True if is valid. public delegate bool IsValidDelegate(Script script); private IsValidDelegate _isValid; private Action