# GetSharedComponent

> Gets a shared component from an entity.

## Definition

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

## GetSharedComponent\<T>(Entity)

Gets a shared component from an entity.

```csharp
public T GetSharedComponent<T>(Entity entity) where T : unmanaged, ISharedComponentData
```

### Parameters

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

### Returns

| Type | Description                     |
| ---- | ------------------------------- |
| T    | A copy of the shared component. |

## GetSharedComponent\<T>(int)

Gets a shared component by index.

```csharp
public T GetSharedComponent<T>(int sharedComponentIndex) where T : unmanaged, ISharedComponentData
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the shared component in the internal shared component list.

### Returns

| Type | Description                     |
| ---- | ------------------------------- |
| T    | A copy of the shared component. |

### Remarks

The ECS framework maintains an internal list of unique shared components. You can get the components in this list, along with their indices using [EntityManager.GetAllUniqueSharedComponents](/engine/7000.0/script-reference/unity/entities/entitymanager/getalluniquesharedcomponents.md). An index in the list is valid and points to the same shared component index as long as the shared component order version from [EntityManager.GetSharedComponentOrderVersion](/engine/7000.0/script-reference/unity/entities/entitymanager/getsharedcomponentorderversion.md) remains the same.
