Unity Editor contains four types of search fields:
A toolbar search field is an input field in toolbars that allows users to enter text to be searched for.
IMGUI
A toolbar search field with a pop-up (dropdown menu) used for filtering search queries.
IMGUI
Search fields appear in toolbars and follow the same principles as other toolbar controls.
Recommended minimum width:
To allow for legible user input, the recommended minimum width for search fields are 150 px, or 20 characters.
The Condensed Search Field in its collapsed state adapts its styling to the context in which it appears, matching the appearance of other icon buttons in the area.
Search results of a query is displayed immediately while a user is typing.
Toolbar Pop-up Search Fields allows users to set object type filters for their search query with a dropdown menu.
In its collapsed state, the Condensed Search Field appears as an icon button with a search icon. Clicking on the search button expands the Condensed Search Field into a Regular Search Field and a collapse button, and automatically places focus on the Search Field.
Clicking on the collapse button collapses the Condensed Search Field back into its collapsed state. If the Search Field is empty, clicking outside of the Search Field removes focus from it and automatically collapses it. If there is input in the Search Field, clicking outside of the Search Field does not automatically collapse it.
A search field can contain following elements:
1. Search / popup search icons
2. Clear icon
3. Body (container)
4. User input
5. Filter label (popup search fields)
6. Popup menu
7. Condensed search button
8. Collapse button
Pop-up search icon is used to open the dropdown menu.
Used to clear user input.
The body of the search field is the container where content (Icons, User input, Filter label) is displayed.
The search query input by the user inside the search field.
Label of the selected filter in pop up search fields.
Condensed state of the Condensed Search Field appears as an icon button.
Collapse button used to collapse a Condensed Search Field from its expanded state.
Default state of a Search Field.
When hovering over a search field body the border will be highlighted. Additionally, the user’s default cursor will switch to a Line Cursor glyph to indicate the nature of the element.
When a search field enters the Focused state its content will be highlighted in addition to its borders. This is because the content is being selected, allowing for the user to interact with it immediately (for example by immediately deleting or copying all of it).
A search field that is disabled will indicate so by having its body “greyed out” and will not accept inputs or react to hovering.
A collapsed Condensed Search Field appears as a search icon button.
A search field that is disabled will indicate so by having its body “greyed out” and will not accept inputs or react to hovering.
Go to Window > UI Toolkit > Samples, to view code samples in C# / USS / UXML.
UI Toolkit
Unity - Scripting API:
ToolbarSearchField
Unity - Scripting API:
ToolbarPopupSearchField
IMGUI