# GetCompanion<T>(EntityManager, Entity)

> Returns the UnityEngine.Component of type T referenced by the entity's companion component.

## Definition

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

```csharp
public static T GetCompanion<T>(this EntityManager entityManager, Entity entity) where T : Component
```

### Parameters

**** (\[EntityManager]\(/engine/7000.0/script-reference/unity/entities/entitymanager)): The entity manager that stores entity.**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The entity to read the companion component from.

### Returns

| Type | Description                                                            |
| ---- | ---------------------------------------------------------------------- |
| T    | The T component referenced by the entity's CompanionComponent\\\<T\\>. |

### Remarks

Resolving the reference is a managed call, so call this method from the main thread. Throws if entity has no CompanionComponent\\\<T\\>.
