Version: 2021.3
Load UXML from C# scripts
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

控件

Element 命名空间 允许的子元素 C# class
BoundsField UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.BoundsField
BoundsIntField UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.BoundsIntField
Box UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Box
Button UnityEngine.UIElements UnityEngine.UIElements.Button
ColorField UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.ColorField
CurveField UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.CurveField
DoubleField UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.DoubleField
DropdownField UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.DropdownField
EnumField UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.EnumField
EnumFlagsField UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.EnumFlagsField
FloatField UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.FloatField
Foldout UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Foldout
GradientField UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.GradientField
GroupBox UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.GroupBox
Hash128Field 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 UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.IntegerField
Label UnityEngine.UIElements UnityEngine.UIElements.Label
LayerField UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.LayerField
LayerMaskField UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.LayerMaskField
ListView UnityEngine.UIElements UnityEngine.UIElements.ListView
LongField UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.LongField
MaskField UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.MaskField
MinMaxSlider UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.MinMaxSlider
ObjectField UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.ObjectField
PopupWindow UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.PopupWindow
ProgressBar UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.ProgressBar
PropertyField UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.PropertyField
RadioButton UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.RadioButton
RadioButtonGroup UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.RadioButtonGroup
RectField UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.RectField
RectIntField UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.RectIntField
RepeatButton UnityEngine.UIElements UnityEngine.UIElements.RepeatButton
ScrollView UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.ScrollView
Scroller UnityEngine.UIElements UnityEngine.UIElements.Scroller
Slider UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Slider
SliderInt UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.SliderInt
TagField UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.TagField
TextElement UnityEngine.UIElements UnityEngine.UIElements.TextElement
TextField UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.TextField
Toggle 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 UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.ToolbarPopupSearchField
ToolbarSearchField UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.ToolbarSearchField
ToolbarSpacer UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.ToolbarSpacer
ToolbarToggle UnityEditor.UIElements 任意数量的 VisualElement UnityEditor.UIElements.ToolbarToggle
TreeView UnityEngine.UIElements UnityEngine.UIElements.TreeView
TwoPaneSplitView UnityEngine.UIElements UnityEngine.UIElements.TwoPaneSplitView
Vector2Field UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Vector2Field
Vector2IntField UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Vector2IntField
Vector3Field UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Vector3Field
Vector3IntField UnityEngine.UIElements 任意数量的 VisualElement UnityEngine.UIElements.Vector3IntField
Vector4Field 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
Load UXML from C# scripts
UXML element BindableElement