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

SearchProvider.fetchColumns

建议更改

成功!

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

关闭

提交失败

由于某种原因,您的建议更改无法提交。请<a>稍后再试</a>。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

public Func<SearchContext,IEnumerable<SearchItem>,IEnumerable<SearchColumn>> fetchColumns;

描述

用于枚举要在搜索表视图中使用的搜索列的处理程序。

如果您需要定义新的列格式来显示自定义值,请参阅 SearchColumnProviderAttribute

static IEnumerable<SearchColumn> FetchColumns(SearchContext context, IEnumerable<SearchItem> items)
{
    yield return new SearchColumn("Performance/Sample Count", "count", nameof(PerformanceMetric));
    yield return new SearchColumn("Performance/Peak Time", "peak", nameof(PerformanceMetric));
    yield return new SearchColumn("Performance/Average Time", "avg", nameof(PerformanceMetric));
    yield return new SearchColumn("Performance/Total Time", "total", nameof(PerformanceMetric));
}

[SearchColumnProvider(nameof(PerformanceMetric))] public static void PerformanceMetric(SearchColumn column) { column.getter = args => { switch (column.selector) { case "count": return EditorPerformanceTracker.GetSampleCount(args.item.id); case "peak": return EditorPerformanceTracker.GetPeakTime(args.item.id); case "avg": return EditorPerformanceTracker.GetAverageTime(args.item.id); case "total": return EditorPerformanceTracker.GetTotalTime(args.item.id); case "age": return EditorPerformanceTracker.GetTimestamp(args.item.id); }

return null; };

if (column.selector != "count") { column.drawer = args => { GUI.Label(args.rect, GetTimeLabel((double)args.value, 0.5d, 2.0d), ItemSelectors.GetItemContentStyle(column)); return args.value; }; } }