# AddChunkComponentData

> Adds a chunk component to the specified entity.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

## AddChunkComponentData\<T>(Entity)

Adds a chunk component to the specified entity.

```csharp
public bool AddChunkComponentData<T>(Entity entity) where T : unmanaged, IComponentData
```

### Parameters

**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The entity.

### Returns

| Type                                                          | Description                                                                                         |
| ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | False if the entity already had the chunk component. The chunk component's value is set regardless. |

### Remarks

Adding a chunk component to an entity changes that entity's archetype and results in the entity being moved to a different chunk, either one that already has an archetype containing the chunk component or a new chunk.

A chunk component is common to all entities in a chunk. You can access a chunk [IComponentData](/engine/7000.0/script-reference/unity/entities/icomponentdata.md) instance through either the chunk itself or through an entity stored in that chunk. In either case, getting or setting the component reads or writes the same data.

**Important:** This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before adding the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

## AddChunkComponentData\<T>(EntityQuery, T)

Adds a chunk component to each of the chunks identified by an EntityQuery and sets the component values.

```csharp
public void AddChunkComponentData<T>(EntityQuery entityQuery, T componentData) where T : unmanaged, IComponentData
```

### Parameters

**** (\[EntityQuery]\(/engine/7000.0/script-reference/unity/entities/entityquery)): The EntityQuery identifying the chunks to modify.**** (T): The data to set.

### Remarks

This function finds all chunks whose archetype satisfies the EntityQuery and adds the specified component to them.

A chunk component is common to all entities in a chunk. You can access a chunk [IComponentData](/engine/7000.0/script-reference/unity/entities/icomponentdata.md) instance through either the chunk itself or through an entity stored in that chunk.

**Important:** This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before adding the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.
