---
title: AddComponentData
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/script-reference/unityengine/component/addcomponentdata
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unityengine/component/addcomponentdata.md
last_updated: 2026-12-01
generated_at: 2026-12-01T07:03:03.635Z
locale: en-us
---

# AddComponentData

> Adds the ComponentData T, an IComponentData, to the GameObject this Component is attached to.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/7000.0/script-reference/unityengine.md)
* **Assembly:** [UnityEngine.CoreModule](/engine/7000.0/script-reference/modules/unityengine-coremodule.md)

## AddComponentData\<T>()

Adds the ComponentData `T`, an `IComponentData`, to the GameObject this Component is attached to.

```csharp
public bool AddComponentData<T>() where T : unmanaged, IComponentData
```

### Returns

| Type                                                          | Description                                                                                                    |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | False if the GameObject already had the ComponentData. Its value is then only set if you pass `componentData`. |

### Remarks

Same as [GameObject.AddComponentData](/engine/7000.0/script-reference/unityengine/gameobject/addcomponentdata.md) on [Component.gameObject](/engine/7000.0/script-reference/unityengine/component/gameobject.md).

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 the GameObject this Component is attached to.

```csharp
public bool AddComponentData<T>(T componentData) where T : unmanaged, IComponentData
```

### Parameters

**** (T): The value of the ComponentData. Without it, the value is zero-initialized.

### Returns

| Type                                                          | Description                                                                                                    |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | False if the GameObject already had the ComponentData. Its value is then only set if you pass `componentData`. |

### Remarks

Same as [GameObject.AddComponentData](/engine/7000.0/script-reference/unityengine/gameobject/addcomponentdata.md) on [Component.gameObject](/engine/7000.0/script-reference/unityengine/component/gameobject.md).

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.
