版本:Unity 6 (6000.0)
语言:英语
使用逻辑封装 UXML 文档
UXML 元素 BindableElement

视觉元素参考

以下表格概述了 UnityEngine.UIElementsUnityEditor.UIElements 命名空间中可用的 视觉元素视觉树中的一个节点,它实例化或派生自 C# VisualElement 类。您可以设置外观样式,定义行为并在屏幕上显示它作为 UI 的一部分。 更多信息
参见 词汇表

基本元素

元素 命名空间 C# 类
BindableElement UnityEngine.UIElements UnityEngine.UIElements.BindableElement
VisualElement UnityEngine.UIElements UnityEngine.UIElements.VisualElement

内置控件

以下表格是对所有可用于 UI(用户界面) 允许用户与您的应用程序交互。Unity 目前支持三种 UI 系统。 更多信息
参见 词汇表
工具包的内置控件的参考。

元素 可绑定 数据类型 命名空间 C# 类
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
RenderingLayerMaskField System.UInt32
UnityEditor.UIElements UnityEditor.UIElements.RenderingLayerMaskField
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
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

仅 C# 控件

以下表格列出了仅在 C# 中可用且没有 UXML 表示的控件。

名称 可绑定 命名空间 C# 类
GenericDropdownMenu UnityEngine.UIElements UnityEngine.UIElements.GenericDropdownMenu

模板

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

UxmlObject 属性

元素 描述 命名空间 允许的子元素 属性
Columns 包含列的描述。必须是支持它的父级的子级,例如 MultiColumnListViewMultiColumnTreeView UnityEngine.UIElements Column
Column 描述一列。必须是 Columns 的子级。 UnityEngine.UIElements name:此列在代码中的名称
title:此列标题中显示的名称
width:此列的默认宽度(以像素为单位)
使用逻辑封装 UXML 文档
UXML 元素 BindableElement