返回

ETComponentView

ComponentView

如果绑定组件没有标识HideInHierarchy隐藏特性,在Component的构造函数中会自动为该组件添加ComponentView,并将ComponentViewcomponent字段与组件绑定

ComponentViewEditor

用于重写ComponentViewInspector面板的编辑器类

  1. 获取ComponentView绑定的Component,检测这个组件是否是热更域的组件,不是的化就不绘制

  2. 调用ComponentViewHelperDraw方法进行绘制

    • ComponentViewHelper的构造函数中,会遍历该程序集中所有标识TypeDrawerAttribute特性的类,并保存到类型绘制队列中

    • Draw方法

      1. 通过obj.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);方法获取该组件中所有公共字段的Type对象数组

      2. 遍历上一步获得的Type对象数组

      3. 校验是否标识了HideInInspector特性,如果标识,则不绘制该对象

      4. 从构造函数保存的类型绘制队列中查找对应类型的ITypeDrawer类型绘制处理类,通过ITypeDrawerHandlesType方法比对是否是对应的类型绘制类

      5. 过滤由于IL反编译错误导致的字段名多余字符串"k__BackingField"

      6. 调用HandlesTypeDrawAndGetNewValue方法对对象进行Inspector面板绘制

      7. DrawAndGetNewValue方法中,会对不同的类型调用不同的EditorGUILayout进行绘制,例如

        string:EditorGUILayout.DelayedTextField

        float:EditorGUILayout.FloatField

        AnimationCurve:EditorGUILayout.CurveField

Licensed under CC BY-NC-SA 4.0
0