1、按内存类型划分
-
非托管Component
用来存储常见的数据类型,比如:
- Blittable types
- bool
- char
- BlobAssetReference<T>(a reference to a Blob data structure)
- Collections.FixedString(a fixed-sized character buffer)
- Collections.FixedList
- Fixed array (only allowed in an unsafe context)
- Other structs that conform to these same restrictions
-
托管 Component
可以存储任何数据类型,但无法使用 Jobs 进行访问,也无法使用 Burst 进行编译,并且声明的 ComponentData 对象必须是无参数的构造函数,当使用其他托管类型数据类型时(比如在 ComponentData 中包含另一个类),还需要添加 IDisposable, ICloneable 的属性功能,同时还要进行 gc 的垃圾回收
需要注意的是,托管类型的组件不会在 chunk 中进行存储,而是存储在其所属 world 中的一个大数组中,只存储这个托管组件的索引,所以当查找 entity 的托管类型组件时,需要额外处理索引查找的工作,所以与非托管组件类型相比,非托管类型组件的查找并不高效
2、按功能类型划分
- 一般的 Component
- Shadred Component:用于消除实体间相同值
- Tag Component:用于标注 Entity 方便查找
- Enableable Component:用于方便禁用 / 启用实体上的组件
- Cleanup Co

最低0.47元/天 解锁文章
1415

被折叠的 条评论
为什么被折叠?



