Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

EntityCommandBuffer.Instantiate

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public Entity Instantiate(Entity e);

Parameters

Parameter Description
e The entity prefab.

Returns

Entity The root entity of the instantiated prefab.

Description

Records a command to create an entity with specified entity prefab.

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.


Declaration

public void Instantiate(Entity e, NativeArray<Entity> entities);

Parameters

Parameter Description
e The entity prefab.
entities A NativeArray that receives the root entities of the instantiated prefabs.

Description

Records a command to create a NativeArray of entities with specified entity prefab.

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.