odin入门和进阶_第二章.md 5.8 KB

在表格中,隐藏标签 HideInTables

![[Pasted image 20240312161207.png]]

只有A和B,Hidden被隐藏了

![[Pasted image 20240312161233.png]]

脚本相关的显隐

![[Pasted image 20240312161856.png]]

加上标签,默认是没这个标签的

![[Pasted image 20240312161922.png]]

![[Pasted image 20240312162003.png]]

因为加了标签,所以没显示脚本

![[Pasted image 20240312162018.png]]

默认是显示的

![[Pasted image 20240312162039.png]]

自定义类型的隐藏HideReferenceObjectPicker

![[Pasted image 20240312165018.png]]

加了标签的,隐藏对应的类属性

![[Pasted image 20240312165055.png]]

继承自Unity.Object的属性显示InlineEditor

![[Pasted image 20240312165224.png]]

其中的调用

![[Pasted image 20240312165258.png]]

![[Pasted image 20240312165424.png]]

多行文本的输入和显示

![[Pasted image 20240312165513.png]]

![[Pasted image 20240312165521.png]]

方形,选择框,可以选择预览体; 还有调用,直接打开odin编辑器的OpenInEditor接口

![[Pasted image 20240312165551.png]]

![[Pasted image 20240312165651.png]]

场景相关的,或者资产相关的选择,筛选

![[Pasted image 20240312165715.png]]

![[Pasted image 20240312165742.png]]

Toggle选择器标签,其中Enabled可以在实例化的时候使用,也可以在类定义上,直接使用

![[Pasted image 20240312165801.png]]

![[Pasted image 20240312165840.png]]

toggle默认是右边的,加了ToggleLeft也可以放置在,左边

![[Pasted image 20240312165904.png]]

![[Pasted image 20240312165924.png]]

Button按钮相关,有各种样式,按钮点击触发逻辑

![[Pasted image 20240312170109.png]]

![[Pasted image 20240312170241.png]]

枚举EnumPaging,和对应可以,触发函数OnValueChanged

![[Pasted image 20240312170554.png]]

![[Pasted image 20240312170619.png]]

根据逻辑,这里的枚举,会切换unity本身的操作模式

![[Pasted image 20240312170646.png]]

枚举后面,可以加按钮EnumToggleButtons 这是定义的枚举结构体

![[Pasted image 20240312170832.png]]

声明调用逻辑

![[Pasted image 20240312170850.png]]

![[Pasted image 20240312170940.png]]

在属性后面,添加按钮InlineButton

![[Pasted image 20240312171028.png]]

![[Pasted image 20240312171046.png]]

BoxGroup组,centerLabel指的是,label文本显示置中,也支持$的字符串,赋值语法,包含各种控件内容

![[Pasted image 20240312172536.png]]

组的下级子控件,是用 / 进行划分

![[Pasted image 20240312172707.png]]

![[Pasted image 20240312172756.png]]

标题组TitleGroup 主副标题,相关逻辑

![[Pasted image 20240312172917.png]]

![[Pasted image 20240312172937.png]]

组的属性折叠FoldoutGroup

![[Pasted image 20240312173016.png]]

![[Pasted image 20240312173037.png]]

水平方向 组的创建 HorizontalGroup

![[Pasted image 20240312173132.png]]

![[Pasted image 20240312173144.png]]

相对应的,垂直组VerticalGroup

![[Pasted image 20240312173218.png]]

![[Pasted image 20240312173250.png]]

页签组TabGroup,用来切换不同的页签组合

![[Pasted image 20240312173350.png]]

![[Pasted image 20240312173423.png]]

Toggle组ToggleGroup相关逻辑,当然也是支持List结构

![[Pasted image 20240312173523.png]]

![[Pasted image 20240312173546.png]]

按钮组相关ButtonGroup

![[Pasted image 20240312173812.png]]

![[Pasted image 20240312173837.png]]

窗体位置,自适应组ResponsiveButtonGroup

![[Pasted image 20240312173936.png]]

可以用于,比较复杂的组合表现

![[Pasted image 20240312174019.png]]

窗口化的时候,也自适应修改大小了

![[Pasted image 20240312174043.png]]

右键菜单,显示对应的,自定义函数功能CustomContextMenu

![[Pasted image 20240313140401.png]]

![[Pasted image 20240313140424.png]]

禁用右键菜单相关DisableContextMenu

![[Pasted image 20240313140631.png]]

右键可以点出菜单的,就是没有被完全禁用的

![[Pasted image 20240313140722.png]]

控件的,两种绘制形式,其中DrawWithUnity标签,指的是,按照unity的形式绘制

![[Pasted image 20240313140832.png]]

![[Pasted image 20240313140907.png]]

标签Indent可以自定义设置,ui缩进

![[Pasted image 20240313141122.png]]

![[Pasted image 20240313141130.png]]

标签InfoBox是可以设置,提示信息,同时还可以设定布尔传参visibleIfMemberName,控制字段是否显示

![[Pasted image 20240313142053.png]]

这个提示,只有在编辑器模式下,才会显示

![[Pasted image 20240313142118.png]]

当然,也可以显示时间相关

![[Pasted image 20240313142151.png]]

![[Pasted image 20240313142133.png]]

运行时,InfoBox提示消失

![[Pasted image 20240313142244.png]]

标签InlineProperty,控制组件的表现和间距相关

![[Pasted image 20240313142410.png]]

![[Pasted image 20240313142434.png]]

LabelText,自定义属性前面的名称

![[Pasted image 20240313142549.png]]

![[Pasted image 20240313142617.png]]

LabelWidth,修改属性标签宽度

![[Pasted image 20240313142714.png]]

![[Pasted image 20240313142722.png]]

OnInspectorGUI 调用函数,创建自定义检查器GUI

![[Pasted image 20240313142905.png]]

这里的逻辑,是监听到变动,就调用DrawPreview函数,创建一个自定义检查器GUI,表现

        GUILayout.BeginVertical(GUI.skin.box);
        GUILayout.Label(this.Texture);
        GUILayout.EndVertical();

![[Pasted image 20240313142923.png]]

PropertyTooltip标签,是鼠标悬停的时候,会出现提示文本内容

![[Pasted image 20240313143246.png]]

![[Pasted image 20240313143505.png]]

SuffixLabel标签,是可以在组件后面,新增自定义提示,配合Overlay属性,观感上,会显示得更加简洁

![[Pasted image 20240313143723.png]]

![[Pasted image 20240313143833.png]]