Documentation

Unity Engine


Unity Engine


Instantiate

Records a command to create an entity with specified entity prefab.
Read time 1 minuteLast updated 2 days ago

Definition

  • Type: Method
  • Namespace: Unity.Entities
  • Assembly: UnityEngine.EntitiesModule

Instantiate(Entity)

Records a command to create an entity with specified entity prefab.
public Entity Instantiate(Entity e)

Parameters

The entity prefab.

Returns

Type

Description

EntityThe root entity of the instantiated prefab.

Remarks

An instantiated entity has the same components and component values as the prefab entity, minus the Prefab tag component. If the source entity was destroyed before playback, this command throws an error.
The returned entity is the root of the instantiated prefab. It is valid for use in subsequent commands on this buffer, but has no chunk until the ECB has been played back EntityCommandBuffer.Playback. For a prefab with a
LinkedEntityGroup
, only the root is allocated at record time. The child entity IDs are only available via the root's
LinkedEntityGroup
buffer after playback.

Instantiate(Entity, NativeArray<Entity>)

Records a command to create a NativeArray of entities with specified entity prefab.
public void Instantiate(Entity e, NativeArray<Entity> entities)

Parameters

The entity prefab.

A NativeArray that receives the root entities of the instantiated prefabs.

Remarks

An instantiated entity has the same components and component values as the prefab entity, minus the Prefab tag component. If the source entity was destroyed before playback, this command throws an error.
The filled entities are the roots of each instantiated prefab. They are valid for use in subsequent commands on this buffer, but have no chunk until the ECB has been played back EntityCommandBuffer.Playback. For a prefab with a
LinkedEntityGroup
, only the roots are allocated at record time. The child entity IDs are only available via each root's
LinkedEntityGroup
buffer after playback.