Version: 2022.2
Encapsulate UXML documents with logic
UXML element BindableElement

UXML 元素参考

以下表格概括了 UnityEngine.UIElements and UnityEditor.UIElements 命名空间中提供的 UXML 元素。

基本元素

Element 命名空间 允许的子元素 C# class
BindableElement UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.BindableElement
VisualElement UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.VisualElement

内置控件

下表是为 UI 工具包提供的所有内置控件的参考。

Element Bindable 数据类型 命名空间 允许的子元素 C# class
BoundsField UnityEngine.Bounds UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.BoundsField
BoundsIntField UnityEngine.BoundsInt UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.BoundsIntField
Box UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Box
Button string UnityEngine.UIElements UnityEngine.UIElements.Button
ColorField UnityEngine.Color UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.ColorField
CurveField UnityEngine.AnimationCurve UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.CurveField
DoubleField double UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.DoubleField
DropdownField string UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.DropdownField
EnumField Enum UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.EnumField
EnumFlagsField Enum UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.EnumFlagsField
FloatField float UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.FloatField
Foldout bool UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Foldout
GradientField UnityEngine.Gradient UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.GradientField
GroupBox UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.GroupBox
Hash128Field UnityEngine.Hash128 UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Hash128Field
HelpBox UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.HelpBox
IMGUIContainer UnityEngine.UIElements UnityEngine.UIElements.IMGUIContainer
Image UnityEngine.UIElements UnityEngine.UIElements.Image
InspectorElement UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.InspectorElement
IntegerField int UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.IntegerField
Label string UnityEngine.UIElements UnityEngine.UIElements.Label
LayerField int UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.LayerField
LayerMaskField int UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.LayerMaskField
ListView IList UnityEngine.UIElements UnityEngine.UIElements.ListView
LongField long UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.LongField
MaskField int UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.MaskField
MinMaxSlider UnityEngine.Vector2 UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.MinMaxSlider
MultiColumnListView UnityEngine.UIElements UnityEngine.UIElements.MultiColumnListView
MultiColumnTreeView UnityEngine.UIElements UnityEngine.UIElements.MultiColumnTreeView
ObjectField UnityEngine.Object UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.ObjectField
PopupWindow string UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.PopupWindow
ProgressBar float UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.ProgressBar
PropertyField UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.PropertyField
RadioButton bool UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.RadioButton
RadioButtonGroup int UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.RadioButtonGroup
RectField UnityEngine.Rect UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.RectField
RectIntField UnityEngine.RectInt UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.RectIntField
RepeatButton string UnityEngine.UIElements UnityEngine.UIElements.RepeatButton
ScrollView UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.ScrollView
Scroller UnityEngine.UIElements UnityEngine.UIElements.Scroller
Slider float UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Slider
SliderInt int UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.SliderInt
TagField string UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.TagField
TextElement string UnityEngine.UIElements UnityEngine.UIElements.TextElement
TextField string UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.TextField
Toggle bool UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Toggle
Toolbar UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.Toolbar
ToolbarBreadcrumbs UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.ToolbarBreadcrumbs
ToolbarButton UnityEditor.UIElements UnityEditor.UIElements.ToolbarButton
ToolbarMenu UnityEditor.UIElements UnityEditor.UIElements.ToolbarMenu
ToolbarPopupSearchField string UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.ToolbarPopupSearchField
ToolbarSearchField string UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.ToolbarSearchField
ToolbarSpacer UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.ToolbarSpacer
ToolbarToggle bool UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.ToolbarToggle
TreeView UnityEngine.UIElements UnityEngine.UIElements.TreeView
TwoPaneSplitView UnityEngine.UIElements UnityEngine.UIElements.TwoPaneSplitView
UnsignedIntegerField System.UInt32 UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.UnsignedIntegerField
UnsignedLongField System.UInt64 UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.UnsignedLongField
Vector2Field UnityEngine.Vector2 UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Vector2Field
Vector2IntField UnityEngine.Vector2Int UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Vector2IntField
Vector3Field UnityEngine.Vector3 UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Vector3Field
Vector3IntField UnityEngine.Vector3Int UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Vector3IntField
Vector4Field UnityEngine.Vector4 UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Vector4Field

模板

Element 描述 命名空间 允许的子元素 Attributes
Template 引用另一个可使用 Instance 元素进行实例化的 UXML 模板。 UnityEngine.UIElements name:此元素的唯一字符串标识符
path:要加载的 UXML 文件的路径
Instance Template 的实例 UnityEngine.UIElements template:要实例化的 Templatename
TemplateContainer 模板容器。 UnityEngine.UIElements BindableElement 的所有属性
template:此模板的字符串标识符

UxmlObject attributes

Element 描述 命名空间 允许的子元素 Attributes
Columns Contains descriptions of columns. Must be a child of a parent that supports it, such as MultiColumnListView or MultiColumnTreeView. UnityEngine.UIElements Column
Column Describes a column. Must be a child of Columns. UnityEngine.UIElements name: The name of this column in code
title: The name displayed in the header of this column
width: The default width of this column in pixels
Encapsulate UXML documents with logic
UXML element BindableElement