Method AddComponentObject
AddComponentObject(EntityQuery, object)
Records a command to add a hybrid component and set its value for all entities matching a query.
Declaration
[Obsolete("Managed-component access (AddComponentObject/GetComponentObject/SetComponentObject) is deprecated and will be removed. Convert your data to an unmanaged IComponentData and use the unmanaged Add/Get/SetComponentData APIs. To reference UnityEngine.Object instances, use UnityObjectRef<T>. First deprecated in 6.6.")]
public void AddComponentObject(EntityQuery entityQuery, object componentData)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityQuery | entityQuery | The query specifying which entities to add the component value to. |
| object | componentData | The component object to add. |
Remarks
The set of entities matching the query is 'captured' in the method call, and the recorded command stores an array of all these entities.
At playback, this command throws an error if one of these entities is destroyed before playback.
Entities which already have the component type will have the component set to the value.
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown in playback if one or more of the entities has been destroyed. (With safety checks disabled, playback will perform invalid and unsafe memory access.). |
| NullReferenceException | Throws if an Allocator was not passed in when the EntityCommandBuffer was created. |
| InvalidOperationException | Throws if this EntityCommandBuffer has already been played back. |
| ArgumentNullException | Throws if componentData is null. |