Version: 2022.1
LanguageEnglish
  • C#

SearchViewState

class in UnityEditor.Search


Implements interfaces:ISerializationCallbackReceiver

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

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

Properties

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.

Constructors

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