搜索表配置用于定义在表格视图中显示搜索结果时的列。
请参阅<a href="Search.DisplayMode.Table.html">DisplayMode.Table</a>。
static SearchTable CreateDecalsTableConfiguration() { var materialIcon = EditorGUIUtility.Load("Material Icon") as Texture; var shaderIcon = EditorGUIUtility.Load("Shader Icon") as Texture; return new SearchTable("decals", new SearchColumn[] { new SearchColumn("DecalsName0", "label", "name", new GUIContent("Name", materialIcon)) { width = 160 }, new SearchColumn("DecalsShader1", "#shader", "name", new GUIContent("Shader", shaderIcon)) { width = 150 }, new SearchColumn("DecalsBaseColor1", "#_BaseColor", "color", new GUIContent("Color", shaderIcon)) { width = 130 }, }); }
创建<a href="Search.SearchViewState.html">SearchViewState</a>时可以使用上述示例。
var selectHandler = args.selectorClosedHandler; var trackingHandler = args.trackingHandler; var query = SearchService.CreateContext(CreateDecalProvider(), $"a={dbName} t={selectContext.requiredTypeNames.First()} shader=Decal"); var viewState = SearchViewState.CreatePickerState("decals", query, selectHandler: (item, canceled) => selectHandler(item?.ToObject(), canceled), trackingHandler: (item) => trackingHandler(item?.ToObject()), null, SearchViewFlags.TableView ); viewState.tableConfig = CreateDecalsTableConfiguration(); var materialIcon = EditorGUIUtility.Load("Material Icon") as Texture; viewState.windowTitle = new GUIContent("Material Decals", materialIcon); viewState.hideAllGroup = true; viewState.position = SearchUtils.GetMainWindowCenteredPosition(new Vector2(600, 400)); s_SearchView = SearchService.ShowPicker(viewState);
SearchTable | 创建一个新的搜索表配置。 |
Clone | 创建搜索表配置的副本。 |
InitFunctors | 根据其格式提供程序初始化所有搜索列函数。 |
LoadFromFile | 从 JSON 文件加载搜索表配置。 |