赞
踩
这里的内容来自官方文档:https://docs.unity3d.com/Manual/UIE-ElementRef.html 可以自行观看
以下均来自官方文档
1.均在UnityEngine.UIElements命名空间下
2.无符号表示允许子元素数量是任意数量的VisualElement
3.X字符表示不允许有子元素
4.不作特殊说明,均包含所有VisualElement属性
所有文本字段的抽象基类
可编辑的文本
-继承自TextInputBaseField< string >
整数(32位)值的文本
长整数(64位)值的文本
单精度浮点值的文本
双精度浮点值的文本
两个文本框,接受按 float 进行编辑的Vector2类型文本
两个文本框,接受按 int 进行编辑的Vector2类型文本
三个文本框,接受按 float 进行编辑的Vector3类型文本
三个文本框,接受按 Int 进行编辑的Vector3类型文本
四个文本框,接受按 float 进行编辑的Vector4类型文本
四个文本框,接受按 float 进行编辑的Rect类型文本
四个文本框,接受按 Int 进行编辑的Rect类型文本
六个文本框,接受按 float 进行编辑的Bounds类型文本
六个文本框,接受按 Int 进行编辑的Bounds类型文本
.fraSmall
{
width:150px;
height:20px;
}
.fraBig
{
width:300px;
height:50px;
}
<TextField class="fraSmall" text="TextField"/>
<editor:IntegerField class="fraSmall"/>
<editor:LongField class="fraSmall"/>
<editor:FloatField class="fraSmall"/>
<editor:DoubleField class="fraSmall"/>
<editor:Vector2Field class="fraSmall"/>
<editor:Vector2IntField class="fraSmall"/>
<editor:Vector3Field class="fraSmall"/>
<editor:Vector3IntField class="fraSmall"/>
<editor:Vector4Field class="fraSmall"/>
<editor:RectField class="fraBig"/>
<editor:RectIntField class="fraBig"/>
<editor:BoundsField class="fraBig"/>
<editor:BoundsIntField class="fraBig"/>
这里都算是比较简单的
用于编辑值的标签和字段
用于编辑字符串类型值的标签和字段
目前PropertyField有关的案例只有一个,是绑定InspectorElement的
Assets/Resources/tank_inspector_styles.uss
.container {
background-color: rgb(80, 80, 80);
flex-direction: column;
}
Label {
background-color: rgb(80, 80, 80);
}
TextField:hover {
background-color: rgb(255, 255, 0);
}
FloatField {
background-color: rgb(0, 0, 255);
}
Assets/Resources/tank_inspector_uxml.uxml
<VisualElement name="row" class="container">
<Label text="Tank Script - Custom Inspector" />
<editor:PropertyField binding-path="tankName" name="tank-name-field" />
<editor:PropertyField binding-path="tankSize" name="tank-size-field" />
</VisualElement>
Assets/TankScript.cs
using UnityEngine;
[ExecuteInEditMode]
public class TankScript : MonoBehaviour
{
public string tankName = "Tank";
public float tankSize = 1;
private void Update()
{
gameObject.name = tankName;
gameObject.transform.localScale = new Vector3(tankSize, tankSize, tankSize);
}
}
Assets/Editor/TankEditor.cs
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
[CustomEditor(typeof(TankScript))]
public class TankEditor : Editor
{
public override VisualElement CreateInspectorGUI()
{
var visualTree = Resources.Load("tank_inspector_uxml") as VisualTreeAsset;
var uxmlVE = visualTree.CloneTree();
uxmlVE.styleSheets.Add(AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Resources/tank_inspector_styles.uss"));
return uxmlVE;
}
}
之后我会再仔细研究
颜色选择器
曲线编辑器
渐变编辑器
对象选择器
在Inspector中显示属性的元素
目前PropertyField有关的案例只有一个,是绑定InspectorElement的
无
<editor:ColorField />
<editor:CurveField />
<editor:GradientField />
<editor:ObjectField />
<!--editor:InspectorElement 在Inspector面板生效,就不写了-->
用于保存工具栏的容器
工具栏按钮
工具栏开关
工具栏的下拉菜单
工具栏的搜索字段
带有搜索选项弹出菜单的搜索字段
在工具栏按钮之间插入固定数量的空白的元素
无
<editor:Toolbar>
<editor:ToolbarButton text="Button"/>
<editor:ToolbarToggle text="Toggle"/>
<editor:ToolbarMenu text="Menu"/>
<editor:ToolbarSearchField text="SearchField"/>
<editor:ToolbarPopupSearchField text="popupSearchField"/>
</editor:Toolbar>
显示元素列表
可滚动视图,带有水平和垂直滚动条
用于在树层次结构中显示元素的视图
UIElements窗口,显示在其他内容之上
.fra
{
width:200px;
height:100px;
}
.fras
{
width:160px;
height:80px;
}
<PopupWindow class="fra" text="wowowo">
<ScrollView class="fras">
<Label text="啊"/>
<Label text="啊"/>
</ScrollView>
</PopupWindow>
ListView和TreeView还没有找到使用方法,之后再做补充
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。