docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Picker

    A customizable UI component for selecting one or multiple items from a list.

    Inheritance
    object
    CallbackEventHandler
    Focusable
    VisualElement
    BaseVisualElement
    ExVisualElement
    Picker
    Picker<TItem, TTitle>
    Implements
    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    IContextOverrideElement
    IAdditionalDataHolder
    IInputElement<IEnumerable<int>>
    IValidatableElement<IEnumerable<int>>
    INotifyValueChanged<IEnumerable<int>>
    ISizeableElement
    IPressable
    Inherited Members
    ExVisualElement.contentContainer
    ExVisualElement.outlineColor
    ExVisualElement.backgroundColor
    ExVisualElement.passMask
    BaseVisualElement.contextPrefix
    BaseVisualElement.scaleOverride
    BaseVisualElement.themeOverride
    BaseVisualElement.langOverride
    BaseVisualElement.layoutDirectionOverride
    BaseVisualElement.preferredTooltipPlacementOverride
    BaseVisualElement.tooltipDelayMsOverride
    BaseVisualElement.GetLayoutDirectionUssClassName(Dir)
    VisualElement.disabledUssClassName
    VisualElement.SetActivePseudoState(bool)
    VisualElement.SetCheckedPseudoState(bool)
    VisualElement.Focus()
    VisualElement.SendEvent(EventBase)
    VisualElement.SetEnabledFromHierarchy(bool)
    VisualElement.SetEnabled(bool)
    VisualElement.MarkDirtyRepaint()
    VisualElement.IsMarkedForRepaint()
    VisualElement.ContainsPoint(Vector2)
    VisualElement.Overlaps(Rect)
    VisualElement.DoMeasure(float, VisualElement.MeasureMode, float, VisualElement.MeasureMode)
    VisualElement.ToString()
    VisualElement.GetClasses()
    VisualElement.ClearClassList()
    VisualElement.AddToClassList(string)
    VisualElement.RemoveFromClassList(string)
    VisualElement.ToggleInClassList(string)
    VisualElement.EnableInClassList(string, bool)
    VisualElement.ClassListContains(string)
    VisualElement.FindAncestorUserData()
    VisualElement.SetBinding(BindingId, Binding)
    VisualElement.GetBinding(BindingId)
    VisualElement.TryGetBinding(BindingId, out Binding)
    VisualElement.GetBindingInfos()
    VisualElement.GetBindingInfos(List<BindingInfo>)
    VisualElement.HasBinding(BindingId)
    VisualElement.ClearBinding(BindingId)
    VisualElement.ClearBindings()
    VisualElement.GetHierarchicalDataSourceContext()
    VisualElement.GetDataSourceContext(BindingId)
    VisualElement.TryGetDataSourceContext(BindingId, out DataSourceContext)
    VisualElement.TryGetLastBindingToUIResult(in BindingId, out BindingResult)
    VisualElement.TryGetLastBindingToSourceResult(in BindingId, out BindingResult)
    VisualElement.Add(VisualElement)
    VisualElement.Insert(int, VisualElement)
    VisualElement.Remove(VisualElement)
    VisualElement.RemoveAt(int)
    VisualElement.Clear()
    VisualElement.ElementAt(int)
    VisualElement.IndexOf(VisualElement)
    VisualElement.Children()
    VisualElement.Sort(Comparison<VisualElement>)
    VisualElement.BringToFront()
    VisualElement.SendToBack()
    VisualElement.PlaceBehind(VisualElement)
    VisualElement.PlaceInFront(VisualElement)
    VisualElement.RemoveFromHierarchy()
    VisualElement.GetFirstOfType<T>()
    VisualElement.GetFirstAncestorOfType<T>()
    VisualElement.Contains(VisualElement)
    VisualElement.FindCommonAncestor(VisualElement)
    VisualElement.viewDataKey
    VisualElement.userData
    VisualElement.canGrabFocus
    VisualElement.focusController
    VisualElement.disablePlayModeTint
    VisualElement.usageHints
    VisualElement.transform
    VisualElement.scaledPixelsPerPoint
    VisualElement.layout
    VisualElement.contentRect
    VisualElement.paddingRect
    VisualElement.worldBound
    VisualElement.localBound
    VisualElement.worldTransform
    VisualElement.hasActivePseudoState
    VisualElement.hasInactivePseudoState
    VisualElement.hasHoverPseudoState
    VisualElement.hasCheckedPseudoState
    VisualElement.hasEnabledPseudoState
    VisualElement.hasDisabledPseudoState
    VisualElement.hasFocusPseudoState
    VisualElement.hasRootPseudoState
    VisualElement.pickingMode
    VisualElement.name
    VisualElement.enabledInHierarchy
    VisualElement.enabledSelf
    VisualElement.languageDirection
    VisualElement.visible
    VisualElement.generateVisualContent
    VisualElement.dataSource
    VisualElement.dataSourcePath
    VisualElement.dataSourceType
    VisualElement.experimental
    VisualElement.hierarchy
    VisualElement.cacheAsBitmap
    VisualElement.parent
    VisualElement.panel
    VisualElement.visualTreeAssetSource
    VisualElement.this[int]
    VisualElement.childCount
    VisualElement.schedule
    VisualElement.style
    VisualElement.resolvedStyle
    VisualElement.customStyle
    VisualElement.styleSheets
    VisualElement.tooltip
    Focusable.Blur()
    Focusable.focusable
    Focusable.tabIndex
    Focusable.delegatesFocus
    CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.RegisterCallbackOnce<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
    CallbackEventHandler.RegisterCallbackOnce<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
    CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
    CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, CallbackOptions)
    CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
    CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, CallbackOptions)
    CallbackEventHandler.UnregisterAllRemovableCallbacks()
    CallbackEventHandler.HasTrickleDownHandlers()
    CallbackEventHandler.HasBubbleUpHandlers()
    CallbackEventHandler.ExecuteDefaultActionAtTarget(EventBase)
    CallbackEventHandler.HandleEventBubbleUp(EventBase)
    CallbackEventHandler.HandleEventTrickleDown(EventBase)
    CallbackEventHandler.ExecuteDefaultAction(EventBase)
    CallbackEventHandler.NotifyPropertyChanged(in BindingId)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.AppUI.UI
    Assembly: Unity.AppUI.dll
    Syntax
    [UxmlElement]
    public abstract class Picker : ExVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder, IInputElement<IEnumerable<int>>, IValidatableElement<IEnumerable<int>>, INotifyValueChanged<IEnumerable<int>>, ISizeableElement, IPressable
    Remarks

    The Picker component provides a flexible way to present users with a list of selectable options. It supports both single and multiple selection modes, making it suitable for various use cases.

    When clicked, the Picker displays a menu containing the available options. Users can select items from this menu, and the selection is reflected in the Picker's title area.

    The component is highly customizable through its various properties and can be styled using USS classes. It supports both keyboard navigation and mouse interaction.

    NOTE: The Picker is an abstract base class. For implementation, use concrete classes like Dropdown that inherit from Picker.

    Examples

    Create a basic single-select picker with string items.

    // Create a basic single-select picker
    var picker = new Dropdown();
    picker.sourceItems = new List<string> { "Small", "Medium", "Large" };
    picker.defaultMessage = "Select size...";
    picker.selectedIndex = 1; // Select "Medium" by default

    Create a multi-select picker with custom item binding.

    // Create a multi-select picker with custom binding
    var picker = new Dropdown();
    var items = new List<string> { "Red", "Green", "Blue" };
    

    picker.sourceItems = items; picker.selectionType = PickerSelectionType.Multiple; picker.bindItem = (item, index) => ; picker.value = new[] { 0, 2 }; // Select "Red" and "Blue"

    Create a picker with validation and change event handling.

    // Create a picker with validation
    var picker = new Dropdown();
    picker.sourceItems = new List<string> { "Option 1", "Option 2", "Option 3" };
    picker.validateValue = (values) => {
        // Require at least one selection
        return values.Any();
    };
    picker.RegisterValueChangedCallback(evt => {
        Debug.Log($"Selection changed: {string.Join(", ", evt.newValue)}");
    });

    Constructors

    Picker()

    Default constructor.

    Declaration
    public Picker()

    Picker(IList, int[])

    Construct a Picker UI element with a provided dynamic collection of items.

    Declaration
    public Picker(IList items, int[] defaultIndices = null)
    Parameters
    Type Name Description
    IList items

    An items collection.

    int[] defaultIndices

    The selected index by default.

    Fields

    appuiPickerMenu

    The Picker menu styling class.

    Declaration
    public const string appuiPickerMenu = "appui-picker__menu"
    Field Value
    Type Description
    string

    caretUssClassName

    The Picker caret styling class.

    Declaration
    public const string caretUssClassName = "appui-picker__caret"
    Field Value
    Type Description
    string

    emphasizedUssClassName

    The Picker emphasized mode styling class.

    Declaration
    public const string emphasizedUssClassName = "appui-picker--emphasized"
    Field Value
    Type Description
    string

    m_Items

    The list of items contained in the Picker.

    Declaration
    protected readonly List<PickerItem> m_Items
    Field Value
    Type Description
    List<PickerItem>

    m_TitleContainer

    The container for the Picker title.

    Declaration
    protected readonly VisualElement m_TitleContainer
    Field Value
    Type Description
    VisualElement

    m_Value

    The list of indices of the selected items.

    Declaration
    protected readonly List<int> m_Value
    Field Value
    Type Description
    List<int>

    sizeUssClassName

    The Picker size styling class.

    Declaration
    public const string sizeUssClassName = "appui-picker--size-"
    Field Value
    Type Description
    string

    titleContainerUssClassName

    The Picker title container styling class.

    Declaration
    public const string titleContainerUssClassName = "appui-picker__titlecontainer"
    Field Value
    Type Description
    string

    titleUssClassName

    The Picker title styling class.

    Declaration
    public const string titleUssClassName = "appui-picker__title"
    Field Value
    Type Description
    string

    trailingContainerUssClassName

    The Picker trailing container styling class.

    Declaration
    public const string trailingContainerUssClassName = "appui-picker__trailingcontainer"
    Field Value
    Type Description
    string

    ussClassName

    The Picker main styling class.

    Declaration
    public const string ussClassName = "appui-picker"
    Field Value
    Type Description
    string

    Properties

    clickable

    Clickable Manipulator for this Picker.

    Declaration
    [CreateProperty]
    public Pressable clickable { get; set; }
    Property Value
    Type Description
    Pressable

    closeOnSelection

    Close the picker menu automatically when an item is selected.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public bool closeOnSelection { get; set; }
    Property Value
    Type Description
    bool

    defaultMessage

    The Picker default message when no item is selected.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public string defaultMessage { get; set; }
    Property Value
    Type Description
    string

    defaultValue

    The Picker default value. This is the value that will be selected if no value is set.

    Declaration
    [CreateProperty]
    public int[] defaultValue { get; set; }
    Property Value
    Type Description
    int[]

    emphasized

    The Picker emphasized mode.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public bool emphasized { get; set; }
    Property Value
    Type Description
    bool

    invalid

    The Picker invalid state.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public bool invalid { get; set; }
    Property Value
    Type Description
    bool

    selectedIndex

    Quick access to the currently selected index for a Picker in Single selection mode.

    Declaration
    [CreateProperty]
    public int selectedIndex { get; set; }
    Property Value
    Type Description
    int

    selectionType

    The Picker selection type.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public PickerSelectionType selectionType { get; set; }
    Property Value
    Type Description
    PickerSelectionType
    Remarks

    If the selection type is changed, the Picker value will be reset.

    size

    The Picker size.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public Size size { get; set; }
    Property Value
    Type Description
    Size

    sourceItems

    The source items collection.

    Declaration
    [CreateProperty]
    public IList sourceItems { get; set; }
    Property Value
    Type Description
    IList

    validateValue

    The Picker validation function.

    Declaration
    [CreateProperty]
    public Func<IEnumerable<int>, bool> validateValue { get; set; }
    Property Value
    Type Description
    Func<IEnumerable<int>, bool>

    value

    The Picker value. This is the index of the selected item.

    Declaration
    [CreateProperty]
    public IEnumerable<int> value { get; set; }
    Property Value
    Type Description
    IEnumerable<int>

    Methods

    GetSizeUssClassName(Size)

    Declaration
    public static string GetSizeUssClassName(Size enumValue)
    Parameters
    Type Name Description
    Size enumValue
    Returns
    Type Description
    string

    OnPickerItemRemoved(PickerItem, int)

    Called when a Picker item is removed.

    Declaration
    protected virtual void OnPickerItemRemoved(PickerItem item, int index)
    Parameters
    Type Name Description
    PickerItem item

    The item to remove.

    int index

    The index of the item to remove.

    OnPickerItemsCreated()

    Called when the Picker items are created.

    Declaration
    protected virtual void OnPickerItemsCreated()

    OnRequestItemCreation(int)

    Create a Picker item.

    Declaration
    protected abstract VisualElement OnRequestItemCreation(int i)
    Parameters
    Type Name Description
    int i

    The index of the item to create.

    Returns
    Type Description
    VisualElement

    The created item.

    OnUnbindItem(VisualElement, int)

    Unbind a Picker item.

    Declaration
    protected abstract void OnUnbindItem(VisualElement item, int index)
    Parameters
    Type Name Description
    VisualElement item

    The item to unbind.

    int index

    The index of the item to unbind.

    OnValueSet()

    Called when the Picker value is set with or without notifying listeners.

    Declaration
    protected virtual void OnValueSet()

    Refresh()

    Refresh the Picker UI.

    Declaration
    public void Refresh()

    RefreshListUI()

    Refresh the Picker list UI.

    Declaration
    protected void RefreshListUI()

    RefreshTitleUI()

    Refresh the Picker title UI.

    Declaration
    protected abstract void RefreshTitleUI()

    RefreshUI()

    Refresh the Picker UI.

    Declaration
    protected void RefreshUI()

    SetValueWithoutNotify(IEnumerable<int>)

    Set the Picker value without notifying any listeners.

    Declaration
    public void SetValueWithoutNotify(IEnumerable<int> newValue)
    Parameters
    Type Name Description
    IEnumerable<int> newValue

    The new value to set.

    Implements

    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    IContextOverrideElement
    IAdditionalDataHolder
    IInputElement<TValue>
    IValidatableElement<TValue>
    INotifyValueChanged<T>
    ISizeableElement
    IPressable

    Extension Methods

    VisualElementExtensions.FindNavController(VisualElement)
    RegisterUpdateCallbackExtensions.RegisterUpdateCallback(VisualElement, EventCallback<UpdateEvent>)
    RegisterUpdateCallbackExtensions.UnregisterUpdateCallback(VisualElement, EventCallback<UpdateEvent>)
    VisualElementExtensions.EnableDynamicTransform(VisualElement, bool)
    VisualElementExtensions.EnablePicking(VisualElement, bool)
    VisualElementExtensions.GetChildren<T>(VisualElement, bool)
    VisualElementExtensions.GetContextProvider<T>(VisualElement)
    VisualElementExtensions.GetContextProvider<T>(VisualElement, string)
    VisualElementExtensions.GetContext<T>(VisualElement)
    VisualElementExtensions.GetContext<T>(VisualElement, string)
    VisualElementExtensions.GetExclusiveRootElement(VisualElement)
    VisualElementExtensions.GetLastAncestorOfType<T>(VisualElement)
    VisualElementExtensions.GetPreferredTooltipPlacement(VisualElement)
    VisualElementExtensions.GetSelfContext<T>(VisualElement)
    VisualElementExtensions.GetSelfContext<T>(VisualElement, string)
    VisualElementExtensions.GetTooltipContent(VisualElement)
    VisualElementExtensions.GetTooltipTemplate(VisualElement)
    VisualElementExtensions.HasAncestorOfType<T>(VisualElement, bool)
    VisualElementExtensions.HasAncestorsOfType<T>(VisualElement)
    VisualElementExtensions.IsContextProvider<T>(VisualElement)
    VisualElementExtensions.IsContextProvider<T>(VisualElement, string)
    VisualElementExtensions.IsInvisible(VisualElement)
    VisualElementExtensions.IsOnScreen(VisualElement)
    VisualElementExtensions.ProvideContext<T>(VisualElement, string, T)
    VisualElementExtensions.ProvideContext<T>(VisualElement, T)
    VisualElementExtensions.RegisterContextChangedCallback<T>(VisualElement, string, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.RegisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.SetPreferredTooltipPlacement(VisualElement, OptionalEnum<PopoverPlacement>)
    VisualElementExtensions.SetTooltipContent(VisualElement, VisualElementExtensions.TooltipContentCallback)
    VisualElementExtensions.SetTooltipTemplate(VisualElement, VisualElement)
    VisualElementExtensions.UnregisterContextChangedCallback<T>(VisualElement, string, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.UnregisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)