Version: 2021.1

SearchAction.closeWindowAfterExecution

切换到手册
public bool closeWindowAfterExecution ;

描述

Indicates if the search view should be closed after the action execution.

new SearchAction("asset", "print_dependencies", new GUIContent("Print Dependencies", null, "Print all dependencies of an asset."))
{
    // If this action is the default, double-clicking on an item to execute this action will not close the Search window.
    closeWindowAfterExecution = false,

    // Handler for a single item.
    handler = (item) =>
    {
        var asset = item.ToObject();
        if (!asset)
            return;
        var path = AssetDatabase.GetAssetPath(asset);
        if (string.IsNullOrEmpty(path))
            return;

        var dependencyPaths = AssetDatabase.GetDependencies(path);
        foreach (var dependencyPath in dependencyPaths)
        {
            var o = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(dependencyPath);
            if (o != null)
                Debug.Log(dependencyPath, o);
        }
    }
},