# ShowWindow

> Creates a new search window.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor.Search](/engine/6000.7/script-reference/unityeditor/search.md)
* **Assembly:** UnityEditor

## ShowWindow(SearchContext, string, float, float, bool, bool, bool, bool)

Creates a new search window.

```csharp
public static ISearchView ShowWindow(SearchContext context = null, string topic = "Unity", float defaultWidth = 850, float defaultHeight = 539, bool saveFilters = true, bool reuseExisting = false, bool multiselect = true, bool dockable = true)
```

### Parameters

**** (\[SearchContext]\(/engine/6000.7/script-reference/unityeditor/search/searchcontext)): Search context to start with.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Topic to search.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Initial width of the window.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Initial height of the window.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): True if user search provider filters should be saved for next search session.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): True if the active providers should be saved for the next session.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): True if the search supports multi-selection.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): 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.

### Returns

| Type                                                                             | Description                              |
| -------------------------------------------------------------------------------- | ---------------------------------------- |
| [ISearchView](/engine/6000.7/script-reference/unityeditor/search/isearchview.md) | Returns the search view window instance. |

### Examples

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

## ShowWindow(SearchViewState)

Creates a new search window.

```csharp
public static ISearchView ShowWindow(SearchViewState viewState)
```

### Parameters

**** (\[SearchViewState]\(/engine/6000.7/script-reference/unityeditor/search/searchviewstate)): Search view state used to open the Search window.

### Returns

| Type                                                                             | Description                              |
| -------------------------------------------------------------------------------- | ---------------------------------------- |
| [ISearchView](/engine/6000.7/script-reference/unityeditor/search/isearchview.md) | Returns the search view window instance. |

### Examples

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