Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PopupField<T>

Generic popup selection field.
Read time 9 minutesLast updated 4 days ago

Definition

public class PopupField<T> : BasePopupField<T, T>, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IBindable, INotifyValueChanged<T>, IMixedValueSupport

Remarks

The following example shows how to create a popup field for a custom data type.

Examples

using System.Collections.Generic;using UnityEngine.UIElements;public class MyData{ public string name; public int id;}public class MyPopupField : PopupField<MyData>{ public MyPopupField() { // Add some example data choices = new List<MyData> { new MyData { name = "First", id = 1 }, new MyData { name = "Second", id = 2 }, new MyData { name = "Third", id = 3 }, }; index = 0; formatSelectedValueCallback = FormatItem; formatListItemCallback = FormatItem; } static string FormatItem(MyData myData) { return myData.name; }}

Static Fields

Value

Description

inputUssClassNameUSS class name of input elements in elements of this type.
labelUssClassNameUSS class name of labels in elements of this type.
ussClassNameUSS class name of elements of this type.

Constructors

Properties

Property

Description

formatListItemCallbackCallback that provides a string representation used to populate the popup menu.
formatSelectedValueCallbackCallback that provides a string representation used to display the selected value.
indexThe currently selected index in the popup menu. Setting the index updates the PopupField<T>.value field and sends a property change notification.
valueThe currently selected value in the popup menu.

Inheritance

Inherited Members