Class ObjectPicker
A rich object/asset picker: search, tabs, a thumbnail-size slider and a custom toolbar slot above a scrollable list, over a resizable preview that adapts to its own height.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class ObjectPicker : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder, INotifyValueChanged<string>
Remarks
The picker is frameless by design — no border and no radius of its own — so the host owns the frame and there is no clipped double border at a rounded corner. Compose it inside a Popover, a Dialog or a FloatingWindow, exactly as ColorPicker is composed by ColorField. It is the intended implementation behind ICustomAssetTargetFieldPicker.
The value is an item id. The empty string is the cleared reference and selects the noneLabel row.
Example
var picker = new ObjectPicker
{
title = "Select Material",
items = new List<ObjectPickerItem>
{
new ObjectPickerItem { id = "bronze", label = "Bronze", type = "Material", tab = "assets" },
},
};
picker.RegisterValueChangedCallback(evt => Debug.Log(evt.newValue));
UXML
<appui:ObjectPicker title="Select Material" show-size-slider="true" show-none="true" />
Constructors
ObjectPicker()
Default constructor.
Declaration
public ObjectPicker()
Fields
closeButtonUssClassName
The ObjectPicker close button styling class.
Declaration
public const string closeButtonUssClassName = "appui-objectpicker__close-button"
Field Value
| Type | Description |
|---|---|
| string |
headerUssClassName
The ObjectPicker header styling class.
Declaration
public const string headerUssClassName = "appui-objectpicker__header"
Field Value
| Type | Description |
|---|---|
| string |
listUssClassName
The ObjectPicker list styling class.
Declaration
public const string listUssClassName = "appui-objectpicker__list"
Field Value
| Type | Description |
|---|---|
| string |
noResultsUssClassName
The ObjectPicker empty-results styling class.
Declaration
public const string noResultsUssClassName = "appui-objectpicker__no-results"
Field Value
| Type | Description |
|---|---|
| string |
noneId
The id of the cleared reference. Unity's convention, and what the none row selects.
Declaration
public const string noneId = ""
Field Value
| Type | Description |
|---|---|
| string |
noneRowUssClassName
The ObjectPicker none-row styling class.
Declaration
public const string noneRowUssClassName = "appui-objectpicker__row--none"
Field Value
| Type | Description |
|---|---|
| string |
previewUssClassName
The ObjectPicker preview styling class.
Declaration
public const string previewUssClassName = "appui-objectpicker__preview"
Field Value
| Type | Description |
|---|---|
| string |
rowLabelUssClassName
The ObjectPicker row label styling class.
Declaration
public const string rowLabelUssClassName = "appui-objectpicker__row__label"
Field Value
| Type | Description |
|---|---|
| string |
rowThumbnailUssClassName
The ObjectPicker row thumbnail styling class.
Declaration
public const string rowThumbnailUssClassName = "appui-objectpicker__row__thumbnail"
Field Value
| Type | Description |
|---|---|
| string |
rowUssClassName
The ObjectPicker row styling class.
Declaration
public const string rowUssClassName = "appui-objectpicker__row"
Field Value
| Type | Description |
|---|---|
| string |
searchUssClassName
The ObjectPicker search bar styling class.
Declaration
public const string searchUssClassName = "appui-objectpicker__search"
Field Value
| Type | Description |
|---|---|
| string |
sizeSliderUssClassName
The ObjectPicker thumbnail-size slider styling class.
Declaration
public const string sizeSliderUssClassName = "appui-objectpicker__size-slider"
Field Value
| Type | Description |
|---|---|
| string |
splitViewUssClassName
The ObjectPicker split view styling class.
Declaration
public const string splitViewUssClassName = "appui-objectpicker__split-view"
Field Value
| Type | Description |
|---|---|
| string |
tabsUssClassName
The ObjectPicker tabs styling class.
Declaration
public const string tabsUssClassName = "appui-objectpicker__tabs"
Field Value
| Type | Description |
|---|---|
| string |
thumbSizeUssClassName
The ObjectPicker thumbnail-size styling class.
Declaration
public const string thumbSizeUssClassName = "appui-objectpicker--thumb-"
Field Value
| Type | Description |
|---|---|
| string |
titleUssClassName
The ObjectPicker title styling class.
Declaration
public const string titleUssClassName = "appui-objectpicker__title"
Field Value
| Type | Description |
|---|---|
| string |
toolbarSlotUssClassName
The ObjectPicker toolbar slot styling class.
Declaration
public const string toolbarSlotUssClassName = "appui-objectpicker__toolbar-slot"
Field Value
| Type | Description |
|---|---|
| string |
toolbarUssClassName
The ObjectPicker toolbar styling class.
Declaration
public const string toolbarUssClassName = "appui-objectpicker__toolbar"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The ObjectPicker main styling class.
Declaration
public const string ussClassName = "appui-objectpicker"
Field Value
| Type | Description |
|---|---|
| string |
Properties
contentContainer
Logical container where child elements are added. If a child is added to this element, the child is added to this element's content container instead.
Declaration
public override VisualElement contentContainer { get; }
Property Value
| Type | Description |
|---|---|
| VisualElement |
Overrides
currentTab
The active tab's value, or null when there are no tabs.
Declaration
public string currentTab { get; }
Property Value
| Type | Description |
|---|---|
| string |
items
The candidates offered by the picker.
Declaration
public IEnumerable<ObjectPickerItem> items { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<ObjectPickerItem> |
noneIconName
Icon for the none row.
Declaration
[CreateProperty]
[UxmlAttribute]
public string noneIconName { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
When set, the row renders like a regular item — icon plus upright, unmuted text — because the field's "none" is a real engine fallback asset rather than an absence. Leave it null for the classic italic placeholder.
noneLabel
The label of the none row, and of the cleared selection in the preview.
Declaration
[CreateProperty]
[UxmlAttribute]
public string noneLabel { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
Lets a field say what "no assignment" actually resolves to — a Text font falling back to the built-in Inter shows "Inter (Default)" rather than the generic placeholder.
previewElement
The preview pane. Exposed so a host can override its renderPreview.
Declaration
public ObjectPickerPreview previewElement { get; }
Property Value
| Type | Description |
|---|---|
| ObjectPickerPreview |
searchBar
The search bar.
Declaration
public SearchBar searchBar { get; }
Property Value
| Type | Description |
|---|---|
| SearchBar |
showCloseButton
Whether a close button is offered in the header, for a windowed picker.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool showCloseButton { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
showNone
Whether the leading none row is offered.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool showNone { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
True by default: a Unity-style object field must always offer "no assignment". The row pins to the top of every tab, ignores the search text, and stays selected while value is null or empty.
showSizeSlider
Whether the thumbnail-size slider is shown.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool showSizeSlider { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
tabsElement
The tab strip.
Declaration
public Tabs tabsElement { get; }
Property Value
| Type | Description |
|---|---|
| Tabs |
thumbSize
The thumbnail size step used by the list rows.
Declaration
[CreateProperty]
[UxmlAttribute]
public ObjectPickerThumbSize thumbSize { get; set; }
Property Value
| Type | Description |
|---|---|
| ObjectPickerThumbSize |
title
The header title. Null or empty hides the whole header unless showCloseButton is true.
Declaration
[CreateProperty]
[UxmlAttribute]
public string title { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
toolbarSlot
The header slot for extra toolbar content, right-aligned beside the size slider.
Declaration
public VisualElement toolbarSlot { get; }
Property Value
| Type | Description |
|---|---|
| VisualElement |
value
The selected item's id.
Declaration
[CreateProperty]
public string value { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
GetThumbSizeUssClassName(ObjectPickerThumbSize)
Declaration
public static string GetThumbSizeUssClassName(ObjectPickerThumbSize enumValue)
Parameters
| Type | Name | Description |
|---|---|---|
| ObjectPickerThumbSize | enumValue |
Returns
| Type | Description |
|---|---|
| string |
SetItems(IEnumerable<ObjectPickerItem>)
Replaces the candidate list.
Declaration
public void SetItems(IEnumerable<ObjectPickerItem> newItems)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ObjectPickerItem> | newItems | The new candidates. Null clears the list. |
SetTabs(IEnumerable<ObjectPickerTab>)
Replaces the tab strip.
Declaration
public void SetTabs(IEnumerable<ObjectPickerTab> newTabs)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ObjectPickerTab> | newTabs | The new tabs. Null or empty hides the strip. |
SetValueWithoutNotify(string)
Sets the value without sending a change event.
Declaration
public void SetValueWithoutNotify(string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | newValue | The new selected id. |
Events
closeRequested
Raised when the header's close button is pressed. The button is only shown when showCloseButton is true.
Declaration
public event Action closeRequested
Event Type
| Type | Description |
|---|---|
| Action |
tabChanged
Raised when the active tab changes, with the new value.
Declaration
public event Action<string> tabChanged
Event Type
| Type | Description |
|---|---|
| Action<string> |