Version: 2021.1
public static Search.ISearchView ShowWindow (Search.SearchContext context, string topic, float defaultWidth, float defaultHeight, bool saveFilters, bool reuseExisting, bool multiselect, bool dockable);

参数

context Search context to start with.
topic Topic to search.
saveFilters True if user search provider filters should be saved for next search session.
reuseExisting True if the active providers should be saved for the next session.
multiselect True if the search supports multi-selection.
defaultWidth Initial width of the window.
defaultHeight Initial height of the window.
dockable If true, creates a dockable search window (that is closed when an item is activated). If false, it creates a dropdown (borderless, undockable and unmovable) version of the search window.

返回

ISearchView Returns the search view window instance.

描述

Creates a new search window.

using UnityEditor;
using UnityEditor.Search;

static class Example_SearchService_ShowWindow
{
    [MenuItem("Examples/SearchService/ShowWindowEmpty")]
    public static void Run1()
    {
        SearchService.ShowWindow()
            .SetSearchText(string.Empty);
    }

    [MenuItem("Examples/SearchService/ShowWindowWithSearchText")]
    public static void Run2()
    {
        SearchService.ShowWindow(SearchService.CreateContext("m: Profiler"));
    }

    [MenuItem("Examples/SearchService/ShowWindowCustomTopic")]
    public static void Run3()
    {
        SearchService.ShowWindow(topic: "My Things")
            .SetSearchText(string.Empty);
    }

    [MenuItem("Examples/SearchService/ShowPopupWindow")]
    public static void Run4()
    {
        SearchService.ShowWindow(defaultWidth: 1300, defaultHeight: 700, dockable: false);
    }
}