核心方法:EntityManager.CreateEntity()+ 多个重载
1. params : ComponentType[] types
Entity entity = World.DefaultGameObjectInjectionWorld.EntityManager.CreateEntity(
typeof(Translation),
typeof(LocalToWorld),
typeof(RenderMesh),
typeof(Scale),
typeof(Unit)
);
2. CreateArchetype( ComponemtType tpye ,xxxx)
原型可挂载多个ComponentData,可配合NativeArray生成多个Entity
{
var entityManager=World.DefaultGameObjectInjectionWorld.EntityManager;
NativeArray<Entity> entityArray = new NativeArray<Entity>(10, Allocator.Temp);
EntityArchetype entityArchetype = entityManager.CreateArchetype(typeof(RenderMesh),
typeof(LocalToWorld),typeof(Translation), typeof(RenderBounds), typeof(Rotation));
entityManager.CreateEntity(entityArchetype,entityArray);
}