Version: 2023.2
Encapsulate UXML documents with logic
UXML element BindableElement

UXML 元素参考

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

基本元素

Element 命名空间 C# class
BindableElement UnityEngine.UIElements UnityEngine.UIElements.BindableElement
VisualElement UnityEngine.UIElements UnityEngine.UIElements.VisualElement

内置控件

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

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

模板

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

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