Version: 2021.3

SearchViewState

class in UnityEditor.Search


实现接口:ISerializationCallbackReceiver

切换到手册

描述

Search view state is used to create new Search windows. See SearchService.ShowWindow.

using UnityEditor;
using UnityEditor.Search;
using UnityEngine.Search;

static class SearchWindows { [MenuItem("Search/Views/Simple Search Bar 1")] public static void SearchViewFlags1() => CreateWindow(SearchViewFlags.None); [MenuItem("Search/Views/Simple Search Bar 2")] public static void SearchViewFlags2() => CreateWindow(SearchViewFlags.EnableSearchQuery); [MenuItem("Search/Views/Simple Search Bar 3")] public static void SearchViewFlags3() => CreateWindow(SearchViewFlags.DisableInspectorPreview); [MenuItem("Search/Views/Simple Search Bar 4")] public static void SearchViewFlags4() => CreateWindow(SearchViewFlags.EnableSearchQuery | SearchViewFlags.DisableInspectorPreview);

static void CreateWindow(SearchViewFlags flags) { var searchContext = SearchService.CreateContext(string.Empty); var viewArgs = new SearchViewState(searchContext, SearchViewFlags.CompactView | flags) { title = flags.ToString() }; SearchService.ShowWindow(viewArgs); } }

变量

flagsVarious search view options.
groupIndicates the group or tab to be selected when the Search window opens.
itemSizeIndicates the item size to be used when the Search window opens.
positionIf defined, indicates the location of the new Search window when it opens.
titleIndicates the search topic title.

构造函数

SearchViewStateCreate search view flags used to create a new Search window.