ET框架学习——ConfigComponent组件和ACategory<T>类

36 篇文章 2 订阅
22 篇文章 5 订阅
  • ACategory<T>类

       ACategory<T>抽象类继承自ACategory类,T实现接口IConfig

public abstract class ACategory : Object
{
	public abstract Type ConfigType { get; }
	public abstract IConfig GetOne();
	public abstract IConfig[] GetAll();
	public abstract IConfig TryGet(int type);
}

       ACategory类内部维护了一些变量,IConfig类是配置的基类,内部只有一个属性Id。

       ACategory<T>类内部维护了一个字典Dictionary<long, IConfig> dict

       重写方法BeginInit来着Object类,根据T类型的名字获取对应的配置内容。遍历内容,利用Json内部API进行转换。然后添加到字典中去,键是T类型的Id值,值就是T类型的对象。

       重写方法ConfigType返回T的类型。另外还有3个Get方法,对字典dict进行操作。

  • ConfigComponent组件

      ConfigComponent组件会扫描所有的有ConfigAttribute标签的配置,加载进来。接通了Awake和Load事件。内部有一个字典Dictionary<Type, ACategory> allConfig用于存储

      Load方法中,获取到ConfigAttribute特性修饰的类的实例,该类必须要继承ACategory抽象类,执行BeginInitEndInit方法。最后将获取到的实例添加到字典中去,键是实例的类型。

     后面是一些对于字典进行操作的Get方法。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
用python帮我把下面标签中的有效数据提取出来<annotation> <folder>converted/CMS/2D目标检测/filter</folder> <filename>converted/CMS/2D目标检测/filter_empty_target_img_after_hash2/0/20230401180910649_61.jpg</filename> <source> <database>Unknown</database> <annotation>Unknown</annotation> <image>Unknown</image> </source> <size> <width>1920</width> <height>1536</height> <depth></depth> </size> <segmented>0</segmented> <object> <name>二轮车</name> <truncated>0</truncated> <occluded>0</occluded> <difficult>0</difficult> <bndbox> <xmin>626.38</xmin> <ymin>808.12</ymin> <xmax>650.03</xmax> <ymax>852.04</ymax> </bndbox> <attributes> <attribute> <name>rotation</name> <value>0.0</value> </attribute> <attribute> <name>track_id</name> <value>6</value> </attribute> <attribute> <name>keyframe</name> <value>True</value> </attribute> </attributes> </object> <object> <name>行人</name> <truncated>0</truncated> <occluded>0</occluded> <difficult>0</difficult> <bndbox> <xmin>1612.74</xmin> <ymin>831.51</ymin> <xmax>1627.34</xmax> <ymax>873.8</ymax> </bndbox> <attributes> <attribute> <name>rotation</name> <value>0.0</value> </attribute> <attribute> <name>track_id</name> <value>8</value> </attribute> <attribute> <name>keyframe</name> <value>True</value> </attribute> </attributes> </object> <object> <name>行人</name> <truncated>0</truncated> <occluded>0</occluded> <difficult>0</difficult> <bndbox> <xmin>1469.0</xmin> <ymin>832.96</ymin> <xmax>1489.43</xmax> <ymax>865.8</ymax> </bndbox> <attributes> <attribute> <name>rotation</name> <value>0.0</value> </attribute> <attribute> <name>track_id</name> <value>9</value> </attribute> <attribute> <name>keyframe</name> <value>True</value> </attribute> </attributes> </object> </annotation>
07-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值