版本:Unity 6 (6000.0)
语言英语
  • C#

SearchAction.handler

建议修改

成功!

感谢您帮助我们提升 Unity 文档质量。虽然我们无法接受所有提交,但我们确实会阅读用户建议的每个修改,并在必要时进行更新。

关闭

提交失败

由于某种原因,无法提交您建议的修改。请在几分钟后<a>重试</a>。感谢您花时间帮助我们提升 Unity 文档质量。

关闭

取消

public Action<SearchItem> handler;

描述

此处理程序用于不支持多选的操作。

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);
        }
    }
},