1.安装

安装两个包

2.初探

实例化

 

注:实例化的实体并不会在Hierarchy视图里面显示,可在EntityDebugger窗口里面显示,因此需要显示的话需要添加Rendermeshcomponent
 

 

3.实现

Data

Data要继承IComponentData接口

component

component 要继承ComponentDataProxy接口

System

system要继承JobComponentSystem

 

注:同一类别的 component 与 system 要在一个文件夹目录下
 

4.对比

Mono (一百个旋转的Cube)

 

ECS (一百个旋转的Cube)

 

总结

用个ECS 帧率是35.7,不用的话是98.8,似乎还没有弄清ECS的运作,还要继续探究
 

后续

原来是大量的Debug.Log消耗了Cup的性能,去掉后对比,生成100个Cube时,帧率都在100FPS左右,而生成10000个cube时,使用ECS能达到50FPS左右,而Mono只能在30FPS左右。

ECS:

100Cube - 99.3FPS

 

10000Cube - 47.2FPS

 

 

Mono:

100 cube - 103FPS

 

 

10000Cube - 27.5FPS