以下表格概括了 UnityEngine.UIElements
and UnityEditor.UIElements
命名空间中提供的 UXML 元素。
Element | 功能 | 命名空间 | 允许的子元素 | Attributes |
---|---|---|---|---|
VisualElement |
所有视觉元素的基类。 | UnityEngine.UIElements |
任意数量的 VisualElement
|
class :以空格分隔的名称列表。style :用于对元素进行样式设置的 USS 指令。name :此元素的唯一字符串标识符。picking-mode :设置为 Position 或 Ignore 。默认值为 Position 。tooltip :鼠标悬停在元素上时,将显示一个字符串。focusable :一个布尔值,指示是否可聚焦某个元素。默认设置为 false (无法聚焦)。这取代了已弃用的 focus-index 元素。tabindex :一个整数,定义元素的 Tab 键移动位置以及在树中的位置。正值会增加 Tab 键移动优先级。默认值为 0。这取代了已弃用的 focus-index 元素。view-data-key :一个字符串,定义用于元素序列化的键。该元素还接受任何其他属性。 |
BindableElement |
可绑定到 SerializedProperty 的元素。属性的值和显示的值是同步的。 |
UnityEngine.UIElements |
任意数量的 VisualElement
|
binding-path :此元素绑定到的属性的路径。 |
Element | 功能 | 命名空间 | 允许的子元素 | Attributes |
---|---|---|---|---|
Box |
此元素与 VisualElement 类似,但在其内容周围绘制一个框。 |
UnityEngine.UIElements |
任意数量的 VisualElement
|
VisualElement 的所有属性 |
TextElement |
用于显示文本的元素。 | UnityEngine.UIElements |
无 |
VisualElement 的所有属性text :元素应该显示的文本。 |
Label |
文本标签。 | UnityEngine.UIElements |
无 |
TextElement 的所有属性 |
Image |
显示图像。 | UnityEngine.UIElements |
无 |
VisualElement 的所有属性 |
IMGUIContainer |
绘制 IMGUI 内容 | UnityEngine.UIElements |
无 |
VisualElement 的所有属性focus-index 默认值为 0 focusable 默认值为 true
|
Foldout |
一个元素,具有开关按钮来显示或隐藏其内容。 | UnityEngine.UIElements |
任意数量的 VisualElement
|
BindableElement 的所有属性 |
Element | 功能 | 命名空间 | 允许的子元素 | Attributes |
---|---|---|---|---|
Template |
引用另一个可使用 Instance 元素进行实例化的 UXML 模板。 |
UnityEngine.UIElements |
无 |
name :此元素的唯一字符串标识符path :要加载的 UXML 文件的路径 |
Instance |
Template 的实例 |
UnityEngine.UIElements |
无 |
template :要实例化的 Template 的 name
|
TemplateContainer |
模板容器。 | UnityEngine.UIElements |
无 |
BindableElement 的所有属性template :此模板的字符串标识符 |
Element | 功能 | 命名空间 | 允许的子元素 | Attributes |
---|---|---|---|---|
BaseField<T> |
所有字段的抽象基类。 | UnityEngine.UIElements |
无 |
BindableElement 的所有属性focus-index 默认值为 0 focusable 默认值为 true label :与字段关联的标签的文本 |
BaseFieldTraits<ValueType, UxmlType> |
UnityEngine.UIElements |
无 |
BaseField<ValueType> 的所有属性value :ValueType 类型的字段的基值 |
|
Button |
标准按钮。 | UnityEngine.UIElements |
无 |
TextElement 的所有属性 |
RepeatButton |
按下时反复执行某项操作的按钮。 | UnityEngine.UIElements |
无 |
TextElement 的所有属性delay :元素执行操作之前的初始延迟(以毫秒为单位)。默认值为 0 interval :每次重复操作之间的间隔(以毫秒为单位)。默认值为 0
|
Toggle |
显示为复选框的一个开关按钮。 | UnityEngine.UIElements |
无 |
BaseFieldTraits<bool, UxmlBoolAttributeDescription> 的所有属性text :开关的右侧标签。 |
Scroller |
滚动条。 | UnityEngine.UIElements |
无 |
VisualElement 的所有属性low-value :滚动条的最小值high-value :滚动条的最大值direction :设置为 Horizontal 或 Vertical 。默认值为 Vertical 。value :滚动条光标的位置 |
Slider |
滑动条。 | UnityEngine.UIElements |
无 |
BaseFieldTraits<float, UxmlFloatAttributeDescription> 的所有属性low-value :滑动条的最小值high-value :滑动条的最大值direction :设置为 Horizontal 或 Vertical 。默认为Horizontal 。page-size :滑动条的页面大小 |
SliderInt |
整数值的滑动条。 | UnityEngine.UIElements |
无 |
BaseFieldTraits<int, UxmlIntAttributeDescription> 的所有属性low-value :滑动条的最小值high-value :滑动条的最大值direction :设置为 Horizontal 或 Vertical 。默认为Horizontal 。page-size :滑动条的页面大小 |
MinMaxSlider |
让用户指定最小值和最大值的滑动条。 | UnityEngine.UIElements |
无 |
BaseField<Vector2> 的所有属性low-limit :滚动条的最小值high-limit :滚动条的最大值min-value :滑动条光标的最小值max-value :滑动条光标的最大值 |
EnumField |
一个字段,接受基础 Enum 的字符串值。 |
UnityEditor.UIElements |
无 |
BaseField<Enum> 的所有属性type :一个字符串,表示 C# 类型的基础 Enum 。如果类型在用户程序集中,则必须将程序集名称添加到类型名称中:MyNamespace.MyEnum, MyAssembly 。始终需要 type 字符串。value :一个字符串,表示该字段的值 |
MaskField |
一个弹出菜单,用户可以从其中选择一组值。 | UnityEditor.UIElements |
无 |
BaseField<int> 的所有属性choices :显示在弹出菜单中的以逗号分隔的列表(最多 32 个选项)value :一个表示字段值的整数(32 位掩码)。 |
LayerField |
一个弹出菜单,用户可以从其中选择图层。 | UnityEditor.UIElements |
无 |
BaseField<int> 的所有属性value :一个表示字段值的整数(选定的图层编号)。 |
LayerMaskField |
一个弹出菜单,用户可以从其中选择一组图层。 | UnityEditor.UIElements |
无 |
MaskField 的所有属性 |
TagField |
一个弹出菜单,用户可以从其中选择标签。 | UnityEditor.UIElements |
无 |
BaseField<string> 的所有属性value :一个表示字段值的字符串(选定的标签名称)。 |
ProgressBar |
一个显示操作进度的进度条。 | UnityEditor.UIElements |
无 |
BindableElement 的所有属性low-value :一个表示进度条最小值的浮点数。默认值为 0。high-value :一个表示进度条最大值的浮点数。默认值为 100。title :一个表示进度条标题的字符串。 |
Element | 功能 | 命名空间 | 允许的子元素 | Attributes |
---|---|---|---|---|
TextInputBaseField<TValueType> |
所有文本字段的抽象基类。 | UnityEngine.UIElements |
无 |
BaseFieldTraits<string, UxmlStringAttributeDescription> 的所有属性text :字段的文本值max-length :该字段可以包含的最大字符数。默认值 (-1 ) 表示对文本长度不设限制。password :一个布尔值,指示是否应使用 maskCharacter 字符来显示字段内容。默认设置为 false 。mask-character :一个字符,在 password 为 true 时显示字段内容。默认值为字符 * 。readonly :一个布尔值,指示该字段为只读字段。默认值为 false
|
TextField |
一个可编辑的文本字段。 | UnityEngine.UIElements |
无 |
TextInputBaseField<string> 的所有属性multiline :一个布尔值,指示文本字段是否将文本显示为多行。设置为 true 可显示为多行,或者设置为 false 可显示为单行并忽略文本中的任何换行符。默认值为 false 。 |
IntegerField |
一个文本字段,可接受整数(32 位)值。 | UnityEditor.UIElements |
无 |
BaseFieldTraits<int, UxmlIntAttributeDescription> 的所有属性 |
LongField |
一个文本字段,可接受长整数(64 位)值。 | UnityEditor.UIElements |
无 |
BaseFieldTraits<long, UxmlLongAttributeDescription> 的所有属性 |
FloatField |
一个文本字段,可接受单精度浮点值。 | UnityEditor.UIElements |
无 |
BaseFieldTraits<float, UxmlFloatAttributeDescription> 的所有属性 |
DoubleField |
一个文本字段,可接受双精度浮点值。 | UnityEditor.UIElements |
无 |
BaseFieldTraits<double, UxmlDoubleAttributeDescription> 的所有属性 |
Vector2Field |
一组(两个)文本字段,可接受浮点值,用于编辑 Vector2 的值。 |
UnityEditor.UIElements |
无 |
BaseField<Vector2> 的所有属性x :X 坐标值y :Y 坐标值 |
Vector2IntField |
一组(两个)文本字段,可接受整数值,用于编辑 Vector2Int 的值。 |
UnityEditor.UIElements |
无 |
BaseField<Vector2Int> 的所有属性x :X 坐标值y :Y 坐标值 |
Vector3Field |
一组(三个)文本字段,可接受浮点值,用于编辑 Vector3 的值。 |
UnityEditor.UIElements |
无 |
BaseField<Vector3> 的所有属性x :X 坐标值y :Y 坐标值z :Z 坐标值 |
Vector3IntField |
一组(三个)文本字段,可接受整数值,用于编辑 Vector3Int 的值。 |
UnityEditor.UIElements |
无 |
BaseField<Vector3Int> 的所有属性x :X 坐标值y :Y 坐标值z :Z 坐标值 |
Vector4Field |
一组(四个)文本字段,可接受浮点值,用于编辑 Vector4 的值。 |
UnityEditor.UIElements |
无 |
BaseField<Vector4> 的所有属性x :X 坐标值y :Y 坐标值z :Z 坐标值w :W 坐标值 |
RectField |
一组(四个)文本字段,可接受浮点值,用于编辑矩形的值。 | UnityEditor.UIElements |
无 |
BaseField<Rect> 的所有属性x :左上角 X 坐标的值y :左上角 Y 坐标的值w :矩形的宽度h :矩形的高度 |
RectIntField |
一组(四个)文本字段,可接受整数值,用于编辑矩形的值。 | UnityEditor.UIElements |
无 |
BaseField<RectInt> 的所有属性x :左上角 X 坐标的值y :左上角 Y 坐标的值w :矩形的宽度h :矩形的高度 |
BoundsField |
一组(六个)文本字段,可接受浮点值,用于编辑边界矩形的值。 | UnityEditor.UIElements |
无 |
BaseField<Bounds> 的所有属性cx :中心 X 坐标的值cy :中心 Y 坐标的值cz :中心 Z 坐标的值ex :范围 X 坐标的值ey :范围 Y 坐标的值ez :范围 Z 坐标的值 |
BoundsIntField |
一组(六个)文本字段,可接受整数值,用于编辑边界矩形的值。 | UnityEditor.UIElements |
无 |
BaseField<BoundsInt> 的所有属性px :位置 X 坐标的值py :位置 Y 坐标的值pz :位置 Z 坐标的值sx :大小 X 坐标的值sy :大小 Y 坐标的值sz :大小 Z 坐标的值 |
Element | 功能 | 命名空间 | 允许的子元素 | Attributes |
---|---|---|---|---|
PropertyField |
一个标签和一个用于编辑值的字段。 | UnityEditor.UIElements |
无 |
VisualElement 的所有属性binding-path :此元素绑定到的属性的路径label :字段的标签 |
ColorField |
拾色器字段。 | UnityEditor.UIElements |
无 |
BaseFieldTraits<Color, UxmlColorAttributeDescription> 的所有属性show-eye-dropper :一个布尔值,指示是否显示取色器。设置为 true 可显示取色器,设置为 false 可隐藏取色器。默认设置为 true 。show-alpha :一个布尔值,指示是否显示 Alpha 控件。设置为 true 可显示该控件,设置为 false 则将其隐藏。默认设置为 true 。hdr :一个布尔值,指示是否使用高动态范围拾色器。设置为 true 可使用拾色器。默认情况下,这设置为 false 。 |
CurveField |
一个曲线编辑器字段。 | UnityEditor.UIElements |
无 |
BaseField<AnimationCurve> 的所有属性 |
GradientField |
一个渐变编辑器字段。 | UnityEditor.UIElements |
无 |
BaseField<Gradient> 的所有属性 |
ObjectField |
一个对象选择器字段。 | UnityEditor.UIElements |
无 |
BaseField<Object> 的所有属性allow-scene-objects :一个布尔值,指示是否可以从场景选择对象。设置为 true 可启用对象选择,设置为 false 则将其禁用。默认情况下,这设置为 true 。 |
InspectorElement |
在 Inspector 窗口中显示属性的元素。 | UnityEditor.UIElements |
任意数量的 VisualElement
|
BindableElement 的所有属性 |
Element | 功能 | 命名空间 | 允许的子元素 | Attributes |
---|---|---|---|---|
Toolbar |
用于容纳工具栏项的容器。 | UnityEditor.UIElements |
任何 VisualElement
|
VisualElement 的所有属性 |
ToolbarButton |
工具栏的按钮。 | UnityEditor.UIElements |
无 |
Button 的所有属性 |
ToolbarToggle |
工具栏的开关。 | UnityEditor.UIElements |
无 |
Toggle 的所有属性 |
ToolbarMenu |
工具栏的下拉菜单。菜单有一个向下的箭头。 | UnityEditor.UIElements |
无 |
TextElement 的所有属性 |
ToolbarSearchField |
工具栏的搜索字段。 | UnityEditor.UIElements |
无 |
VisualElement 的所有属性 |
ToolbarPopupSearchField |
一个带有搜索选项弹出菜单的搜索字段。 | UnityEditor.UIElements |
无 |
VisualElement 的所有属性 |
ToolbarSpacer |
一个元素,用于在工具栏按钮之间插入固定数量的空格。 | UnityEditor.UIElements |
无 |
VisualElement 的所有属性 |
Element | 功能 | 命名空间 | 允许的子元素 | Attributes |
---|---|---|---|---|
ListView |
显示元素列表。 | UnityEngine.UIElements |
无 |
VisualElement 的所有属性item-height :列表中每一项的高度(以像素为单位) |
ScrollView |
一个带有水平和垂直滚动条的可滚动视图。 | UnityEngine.UIElements |
任意数量的 VisualElement
|
VisualElement 的所有属性mode :滚动视图的模式。默认设置为 ScrollViewMode.Vertical show-horizontal-scroller :一个布尔值,指示是否显示水平滚动条。默认设置为 false show-vertical-scroller :一个布尔值,指示是否显示垂直滚动条。默认情况下,这设置为 false horizontal-page-size :水平滚动条的页面大小值vertical-page-size :垂直滚动条的页面大小 |
TreeView |
在树层级视图中显示元素的视图。 | UnityEngine.UIElements |
任意数量的 VisualElement
|
VisualElement 的所有属性item-height :显示的基础列表中的项高度 |
PopupWindow |
一个显示在其他内容之上的 UIElements 窗口。 | UnityEditor.UIElements |
无 |
TextElement 的所有属性 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.