Method CreateEntity
CreateEntity(EntityArchetype)
Creates an entity having the specified archetype.
Declaration
public Entity CreateEntity(EntityArchetype archetype)
Parameters
Type | Name | Description |
---|---|---|
EntityArchetype | archetype | The archetype for the new entity. |
Returns
Type | Description |
---|---|
Entity | The Entity object that you can use to access the entity. |
Remarks
The EntityManager creates the entity in the first available chunk with the matching archetype that has enough space.
Important: This function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before creating the entity and no additional Jobs can start before the function is finished. A sync point can cause a drop in performance because the ECS framework may not be able to make use of the processing power of all available cores.
CreateEntity(ComponentType[])
Creates an entity having components of the specified types.
Declaration
public Entity CreateEntity(params ComponentType[] types)
Parameters
Type | Name | Description |
---|---|---|
ComponentType[] | types | The types of components to add to the new entity. |
Returns
Type | Description |
---|---|
Entity | The Entity object that you can use to access the entity. |
Remarks
The EntityManager creates the entity in the first available chunk with the matching archetype that has enough space.
Important: This function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before creating the entity and no additional Jobs can start before the function is finished. A sync point can cause a drop in performance because the ECS framework may not be able to make use of the processing power of all available cores.
CreateEntity()
Creates an entity with no components.
Declaration
public Entity CreateEntity()
Returns
Type | Description |
---|---|
Entity | The Entity object that you can use to access the entity. |
Remarks
The EntityManager creates the entity in the first available chunk with the archetype having no components.
Important: This function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before creating the entity and no additional Jobs can start before the function is finished. A sync point can cause a drop in performance because the ECS framework may not be able to make use of the processing power of all available cores.
CreateEntity(EntityArchetype, NativeArray<Entity>)
Creates a set of entities of the specified archetype.
Declaration
public void CreateEntity(EntityArchetype archetype, NativeArray<Entity> entities)
Parameters
Type | Name | Description |
---|---|---|
EntityArchetype | archetype | The archetype defining the structure for the new entities. |
NativeArray<Entity> | entities | An array to hold the Entity objects needed to access the new entities. The length of the array determines how many entities are created. |
Remarks
Fills the NativeArray
object assigned to the entities
parameter with the Entity objects of the created entities. Each entity
has the components specified by the EntityArchetype object assigned
to the archetype
parameter. The EntityManager adds these entities to the World entity list. Use the
Entity objects in the array for further processing, such as setting the component values.
CreateEntity(EntityArchetype, Int32, Allocator)
Creates a set of entities of the specified archetype.
Declaration
public NativeArray<Entity> CreateEntity(EntityArchetype archetype, int entityCount, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
EntityArchetype | archetype | The archetype defining the structure for the new entities. |
Int32 | entityCount | The number of entities to create with the specified archetype. |
Allocator | allocator | How the created native array should be allocated. |
Returns
Type | Description |
---|---|
NativeArray<Entity> | A NativeArray of entities with the given archetype. |
Remarks
Creates a NativeArray of entities,
each of which has the components specified by the EntityArchetype object assigned
to the archetype
parameter. The EntityManager adds these entities to the World entity list.
CreateEntity(EntityArchetype, Int32)
Creates a set of entities of the specified archetype.
Declaration
public void CreateEntity(EntityArchetype archetype, int entityCount)
Parameters
Type | Name | Description |
---|---|---|
EntityArchetype | archetype | The archetype defining the structure for the new entities. |
Int32 | entityCount | The number of entities to create with the specified archetype. |
Remarks
Unlike the other overloads, this does not create an array of Entity values. You don't always need the Entity value of a newly created entity because maybe you only need to access the entity through queries.