Version: 2021.3
언어: 한국어
public Func<SearchItem,SearchContext,string> fetchDescription ;

설명

Handler to provide an asynchronous description for an item. Is called when the item is about to be displayed. Allows a plugin provider to only fetch long descriptions when they are needed.

[SearchItemProvider]
internal static SearchProvider CreateProvider()
{
    return new SearchProvider(id, name)
    {
        filterId = "tree:",
        priority = 99999, // put example provider at a low priority
        fetchItems = (context, items, provider) =>
        {
            // That provider searches for tree prefabs in the project
            var results = AssetDatabase.FindAssets("t:Prefab tree" + context.searchQuery);
            foreach (var guid in results)
            {
                items.Add(provider.CreateItem(context, AssetDatabase.GUIDToAssetPath(guid), null, null, null, null));
            }
            return null;
        },
        #pragma warning disable UNT0008 // Null propagation on Unity objects
        // Use fetch to load the asset asynchronously on display
        fetchThumbnail = (item, context) => AssetDatabase.GetCachedIcon(item.id) as Texture2D,
        fetchPreview = (item, context, size, options) => AssetDatabase.GetCachedIcon(item.id) as Texture2D,
        fetchLabel = (item, context) => AssetDatabase.LoadMainAssetAtPath(item.id)?.name,
        fetchDescription = (item, context) => AssetDatabase.LoadMainAssetAtPath(item.id)?.name,
        toObject = (item, type) => AssetDatabase.LoadMainAssetAtPath(item.id),
        #pragma warning restore UNT0008 // Null propagation on Unity objects
        // Shows handled actions in the preview inspector
        // Shows inspector view in the preview inspector (uses toObject)
        showDetailsOptions = ShowDetailsOptions.Inspector | ShowDetailsOptions.Actions,
        trackSelection = (item, context) =>
        {
            var obj = AssetDatabase.LoadMainAssetAtPath(item.id);
            if (obj != null)
                EditorGUIUtility.PingObject(obj.GetInstanceID());
        },
        startDrag = (item, context) =>
        {
            var obj = AssetDatabase.LoadMainAssetAtPath(item.id);
            if (obj != null)
            {
                DragAndDrop.PrepareStartDrag();
                DragAndDrop.objectReferences = new Object[] { obj };
                DragAndDrop.StartDrag(item.label);
            }
        }
    };
}