ComponentView
如果绑定组件没有标识HideInHierarchy
隐藏特性,在Component的构造函数中会自动为该组件添加ComponentView
,并将ComponentView
的component
字段与组件绑定
ComponentViewEditor
用于重写ComponentView
的Inspector
面板的编辑器类
-
获取
ComponentView
绑定的Component
,检测这个组件是否是热更域的组件,不是的化就不绘制 -
调用
ComponentViewHelper
的Draw
方法进行绘制-
在
ComponentViewHelper
的构造函数中,会遍历该程序集中所有标识TypeDrawerAttribute
特性的类,并保存到类型绘制队列中 -
Draw
方法-
通过
obj.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
方法获取该组件中所有公共字段的Type对象数组 -
遍历上一步获得的Type对象数组
-
校验是否标识了
HideInInspector
特性,如果标识,则不绘制该对象 -
从构造函数保存的类型绘制队列中查找对应类型的
ITypeDrawer
类型绘制处理类,通过ITypeDrawer
的HandlesType
方法比对是否是对应的类型绘制类 -
过滤由于IL反编译错误导致的字段名多余字符串
"k__BackingField"
-
调用
HandlesType
的DrawAndGetNewValue
方法对对象进行Inspector
面板绘制 -
在
DrawAndGetNewValue
方法中,会对不同的类型调用不同的EditorGUILayout
进行绘制,例如string:EditorGUILayout.DelayedTextField
float:EditorGUILayout.FloatField
AnimationCurve:EditorGUILayout.CurveField
-
-