Documentation

Unity Engine

Download Unity

Unity Engine

AddComponentData

Adds the ComponentData T, an IComponentData, to this GameObject.
Read time 1 minuteLast updated 6 hours ago

Definition

AddComponentData<T>()

Adds the ComponentData
T
, an
IComponentData
, to this GameObject.
public bool AddComponentData<T>() where T : unmanaged, IComponentData

Returns

Type

Description

boolFalse if the GameObject already had the ComponentData. Its value is then only set if you pass
componentData
.

Remarks

Throws an
ArgumentException
if the GameObject has been destroyed.
This is a structural change: it waits for all jobs in the World to complete. To make it from a job or a system without waiting, record it in a
Unity.Entities.EntityCommandBuffer
instead.

AddComponentData<T>(T)

Adds the ComponentData
T
, an
IComponentData
, to this GameObject.
public bool AddComponentData<T>(T componentData) where T : unmanaged, IComponentData

Parameters

componentData

T
The value of the ComponentData. Without it, the value is zero-initialized.

Returns

Type

Description

boolFalse if the GameObject already had the ComponentData. Its value is then only set if you pass
componentData
.

Remarks

Throws an
ArgumentException
if the GameObject has been destroyed.
This is a structural change: it waits for all jobs in the World to complete. To make it from a job or a system without waiting, record it in a
Unity.Entities.EntityCommandBuffer
instead.