Class QuickSearch
Quick Search Editor Window
Namespace: Unity.QuickSearch
Syntax
public class QuickSearch : EditorWindow, ISearchView, IDisposable
Examples
using Unity.QuickSearch; [MenuItem("Tools/Quick Search %space", priority = 42)] private static void OpenQuickSearch() { QuickSearch.Open(); }
Properties
context
Returns the current view search context
Declaration
public SearchContext context { get; }
Property Value
Type | Description |
---|---|
SearchContext |
Implements
displayMode
Indicates how the data is displayed in the UI.
Declaration
public DisplayMode displayMode { get; }
Property Value
Type | Description |
---|---|
DisplayMode |
Implements
filterCallback
When QuickSearch is used in Object Picker mode, this callback is triggered when the search item list is computed from the query allowing a user to apply further filtering on the object set.
Declaration
public Func<SearchItem, bool> filterCallback { get; set; }
Property Value
Type | Description |
---|---|
Func<SearchItem, Boolean> |
Implements
itemIconSize
Defines the size of items in the search view.
Declaration
public float itemIconSize { get; set; }
Property Value
Type | Description |
---|---|
Single |
Implements
multiselect
Allow multi-selection or not.
Declaration
public bool multiselect { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
results
Return the list of all search results.
Declaration
public ISearchList results { get; }
Property Value
Type | Description |
---|---|
ISearchList |
Implements
selectCallback
When QuickSearch is used in Object Picker mode, this callback is triggered when an object is selected.
Declaration
public Action<SearchItem, bool> selectCallback { get; set; }
Property Value
Type | Description |
---|---|
Action<SearchItem, Boolean> |
Implements
selection
Returns the selected item in the view
Declaration
public SearchSelection selection { get; }
Property Value
Type | Description |
---|---|
SearchSelection |
Implements
trackingCallback
Callback used to override the tracking behavior.
Declaration
public Action<SearchItem> trackingCallback { get; set; }
Property Value
Type | Description |
---|---|
Action<SearchItem> |
Implements
Methods
AddSelection(Int32[])
Add items to the current selection.
Declaration
public void AddSelection(params int[] selection)
Parameters
Type | Name | Description |
---|---|---|
Int32[] | selection | List containing indices of items to add to current selection. |
Implements
Create(Boolean)
Creates a new instance of a Quick Search window but does not show it immediately allowing a user to setup filter before showing the window.
Declaration
public static QuickSearch Create(bool reuseExisting = false)
Parameters
Type | Name | Description |
---|---|---|
Boolean | reuseExisting | If true, try to reuse an already existing instance of QuickSearch. If false will create a new QuickSearch window. |
Returns
Type | Description |
---|---|
QuickSearch | Returns the Quick Search editor window instance. |
Create(SearchContext, String, Boolean, Boolean, Boolean)
Create a new quick search window that will be initialized with a specific context.
Declaration
public static QuickSearch Create(SearchContext context, string topic = "anything", bool saveFilters = true, bool reuseExisting = false, bool multiselect = true)
Parameters
Type | Name | Description |
---|---|---|
SearchContext | context | Search context to start with |
String | topic | Topic to seached |
Boolean | saveFilters | True if user provider filters should be saved for next search session |
Boolean | reuseExisting | True if we should reuse an opened window |
Boolean | multiselect | True if the search support multi-seleciton or not. |
Returns
Type | Description |
---|---|
QuickSearch |
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing |
ExecuteAction(SearchAction, SearchItem[], Boolean)
Execute a Search Action on a given list of items.
Declaration
public void ExecuteAction(SearchAction action, SearchItem[] items, bool endSearch = true)
Parameters
Type | Name | Description |
---|---|---|
SearchAction | action | Action to execute. |
SearchItem[] | items | Items to apply the action on. |
Boolean | endSearch | If true, executing this action will close the Quicksearch window. |
Implements
Open(Single, Single, Boolean, Boolean)
Creates and open a new instance of Quick Search
Declaration
public static QuickSearch Open(float defaultWidth = 850F, float defaultHeight = 539F, bool dockable = false, bool reuseExisting = false)
Parameters
Type | Name | Description |
---|---|---|
Single | defaultWidth | Initial width of the window. |
Single | defaultHeight | Initial height of the window. |
Boolean | dockable | If true, creates a dockable QuickSearch Window (that will be closed when an item is activated). If false, it will create a DropDown (borderless, undockable and unmovable) version of QuickSearch. |
Boolean | reuseExisting | If true, try to reuse an already existing instance of QuickSearch. If false will create a new QuickSearch window. |
Returns
Type | Description |
---|---|
QuickSearch | Returns the Quick Search editor window instance. |
OpenWithContextualProvider(String[])
Open the quick search window using a specific context (activating specific filters and such).
Declaration
public static QuickSearch OpenWithContextualProvider(params string[] providerIds)
Parameters
Type | Name | Description |
---|---|---|
String[] | providerIds | Unique ids of providers to enable when popping QuickSearch. |
Returns
Type | Description |
---|---|
QuickSearch | Returns a new shown instance of QuickSearch. |
Examples
[MenuItem("Tools/Search Menus _F1")] public static void SearchMenuItems() { QuickSearch.OpenWithContextualProvider("menu"); }
PopFilterWindow()
Open the Quick Search filter window to edit active filters.
Declaration
public void PopFilterWindow()
Implements
PopSearchQueryCreateWindow()
Open the Search Query creation window.
Declaration
public void PopSearchQueryCreateWindow()
Refresh()
Re-fetch the search results and refresh the UI.
Declaration
public void Refresh()
Implements
SetSearchText(String, TextCursorPlacement)
Sets the search query text.
Declaration
public void SetSearchText(string searchText, TextCursorPlacement moveCursor = TextCursorPlacement.MoveLineEnd)
Parameters
Type | Name | Description |
---|---|---|
String | searchText | Text to be displayed in the search view. |
TextCursorPlacement | moveCursor | Where to place the cursor after having set the search text |
Implements
SetSelection(Int32[])
Set which items are selected in the view.
Declaration
public void SetSelection(params int[] selection)
Parameters
Type | Name | Description |
---|---|---|
Int32[] | selection | List containing indices of items to select. |
Implements
ShowItemContextualMenu(SearchItem, Rect)
Show a contextual menu for the specified item.
Declaration
public void ShowItemContextualMenu(SearchItem item, Rect position)
Parameters
Type | Name | Description |
---|---|---|
SearchItem | item | Item affected by the contextual menu. |
Rect | position | Where the menu should be drawn on screen (generally item position) |
Implements
ShowObjectPicker(Action<UnityEngine.Object, Boolean>, Action<UnityEngine.Object>, Func<UnityEngine.Object, Boolean>, String, String, Type, Single, Single, Boolean)
Use Quick Search to as an object picker to select any object based on the specified filter type.
Declaration
public static QuickSearch ShowObjectPicker(Action<UnityEngine.Object, bool> selectHandler, Action<UnityEngine.Object> trackingHandler, Func<UnityEngine.Object, bool> pickerConstraintHandler, string searchText, string typeName, Type filterType, float defaultWidth = 850F, float defaultHeight = 539F, bool dockable = false)
Parameters
Type | Name | Description |
---|---|---|
Action<UnityEngine.Object, Boolean> | selectHandler | Callback to trigger when a user selects an item. |
Action<UnityEngine.Object> | trackingHandler | Callback to trigger when the user is modifying QuickSearch selection (i.e. tracking the currently selected item) |
Func<UnityEngine.Object, Boolean> | pickerConstraintHandler | Callback that is called to provide additionnal filtering when QuickSearch is populating its object list. |
String | searchText | Initial search text for QuickSearch. |
String | typeName | Type name of the object to select. Can be used to replace filterType. |
Type | filterType | Type of the object to select. |
Single | defaultWidth | Initial width of the window. |
Single | defaultHeight | Initial height of the window. |
Boolean | dockable | If true, creates a dockable QuickSearch Window (that will be closed when an item is activated). If false, it will create a DropDown (borderless, undockable and unmovable) version of QuickSearch. |
Returns
Type | Description |
---|---|
QuickSearch |
ShowWindow(Single, Single, Boolean)
Open the default Quick Search window using default settings.
Declaration
public QuickSearch ShowWindow(float defaultWidth = 850F, float defaultHeight = 538F, bool dockable = false)
Parameters
Type | Name | Description |
---|---|---|
Single | defaultWidth | Initial width of the window. |
Single | defaultHeight | Initial height of the window. |
Boolean | dockable | If true, creates a dockable QuickSearch Window (that will be closed when an item is activated). If false, it will create a DropDown (borderless, undockable and unmovable) version of QuickSearch. |
Returns
Type | Description |
---|---|
QuickSearch | Returns the Quick Search editor window instance. |