docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class AssetTargetField

    A field that displays a reference to an asset and lets the user reassign or clear it.

    Inheritance
    object
    CallbackEventHandler
    Focusable
    VisualElement
    BaseVisualElement
    AssetTargetField
    Implements
    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    IContextOverrideElement
    IAdditionalDataHolder
    IInputElement<AssetReference>
    IValidatableElement<AssetReference>
    INotifyValueChanged<AssetReference>
    ISizeableElement
    IPressable
    Inherited Members
    BaseVisualElement.contextPrefix
    BaseVisualElement.densityOverride
    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 class AssetTargetField : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder, IInputElement<AssetReference>, IValidatableElement<AssetReference>, INotifyValueChanged<AssetReference>, ISizeableElement, IPressable
    Remarks

    This is the UITK counterpart of BOTH the registry's asset-target-field and its object-field. The two registry components are the same control — object-field is asset-target-field without the size prop and without the clear button — so UITK deliberately ships one class rather than a near-duplicate.

    The field renders, left to right: an optional leading type icon, the referenced asset's name (or the empty-state label), a clear button shown only while something is assigned, and a pick button that opens customPicker.

    Example

    var field = new AssetTargetField
    {
        type = typeof(Material),
        value = new AssetReference { name = "Bronze", type = "Material", typeIcon = "sphere" },
    };
    field.customPicker = myObjectPickerHost;

    UXML

    <appui:AssetTargetField size="Md" show-clear-button="true" empty-label="None" />

    Constructors

    AssetTargetField()

    Default constructor.

    Declaration
    public AssetTargetField()

    Fields

    clearButtonUssClassName

    The AssetTargetField clear button styling class.

    Declaration
    public const string clearButtonUssClassName = "appui-assettargetfield__clear-button"
    Field Value
    Type Description
    string

    iconUssClassName

    The AssetTargetField leading icon styling class.

    Declaration
    public const string iconUssClassName = "appui-assettargetfield__icon"
    Field Value
    Type Description
    string

    labelUssClassName

    The AssetTargetField label styling class.

    Declaration
    public const string labelUssClassName = "appui-assettargetfield__label"
    Field Value
    Type Description
    string

    pickButtonUssClassName

    The AssetTargetField pick button styling class.

    Declaration
    public const string pickButtonUssClassName = "appui-assettargetfield__pick-button"
    Field Value
    Type Description
    string

    sizeUssClassName

    The AssetTargetField size styling class.

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

    ussClassName

    The AssetTargetField main styling class.

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

    Properties

    clearButton

    The button that clears the reference. Only visible while a value is assigned and showClearButton is true.

    Declaration
    public IconButton clearButton { get; }
    Property Value
    Type Description
    IconButton

    clickable

    Clickable Manipulator for this AssetTargetField.

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

    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
    VisualElement.contentContainer

    customPicker

    The picker opened when the field, or its pick button, is pressed.

    Declaration
    [CreateProperty]
    public ICustomAssetTargetFieldPicker customPicker { get; set; }
    Property Value
    Type Description
    ICustomAssetTargetFieldPicker
    Remarks

    Null by default — the field has no way to enumerate assets on its own. Pressing the pick button with no picker assigned raises pickRequested and does nothing else, which is what lets the field ship before a picker host exists.

    emptyLabel

    The label shown when no asset is assigned.

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

    Defaults to None, matching the registry. It is fed through LocalizedTextElement, so it can be a localization key.

    iconElement

    The leading type icon.

    Declaration
    public Icon iconElement { get; }
    Property Value
    Type Description
    Icon

    invalid

    Whether the current value of the AssetTargetField is valid or not. This is determined by the validateValue function.

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

    pickButton

    The button that opens customPicker.

    Declaration
    public IconButton pickButton { get; }
    Property Value
    Type Description
    IconButton

    showClearButton

    Whether the clear button is offered at all. When true the button still only shows while a value is assigned, because there is nothing to clear otherwise.

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

    size

    The size of the element.

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

    type

    The type of the AssetReference that this field accepts. This is used to filter the assets that can be assigned to this field, and it drives the leading icon when the assigned value carries no typeIcon.

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

    validateValue

    A function that validates the value of the AssetTargetField. It returns true if the value is valid, false otherwise.

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

    value

    The current value of the AssetTargetField.

    Declaration
    [CreateProperty]
    public AssetReference value { get; set; }
    Property Value
    Type Description
    AssetReference

    Methods

    ClearValue()

    Clears the assigned reference, as the clear button does.

    Declaration
    public void ClearValue()
    Remarks

    Named ClearValue rather than Clear because Clear() removes every child, so a field held in a VisualElement variable would tear out its own icon, label and buttons instead of dropping the reference.

    GetSizeUssClassName(Size)

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

    OpenPicker()

    Opens customPicker, as the pick button does.

    Declaration
    public void OpenPicker()

    SetValueWithoutNotify(AssetReference)

    Sets the value of the AssetTargetField without sending a change event.

    Declaration
    public void SetValueWithoutNotify(AssetReference newValue)
    Parameters
    Type Name Description
    AssetReference newValue

    The new value to set.

    Events

    cleared

    Raised when the user clears the reference with the clear button. The registry's onClear callback. The value change itself is also reported through the usual ChangeEvent_1.

    Declaration
    public event Action cleared
    Event Type
    Type Description
    Action

    pickRequested

    Raised when the user asks for the picker, whether or not a customPicker is assigned. The registry's onPick callback.

    Declaration
    public event Action pickRequested
    Event Type
    Type Description
    Action

    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)