> For the complete documentation index, see [llms.txt](https://heroicsolo.gitbook.io/heroic-engine/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://heroicsolo.gitbook.io/heroic-engine/basics/engine-utilities/componentextensions.md).

# ComponentExtensions

This class allows you to copy Unity components from certain gameobjects, so you can add these copied components onto other gameobjects if needed.

### Available methods

```csharp
public static T GetCopyOf<T>(this T comp, T other) where T : Component
```

*This extension method creates copy of given component.*

*Example:*

```csharp
var rb = firstGO.GetComponent<Rigidbody>();
secondGO.AddComponent<Rigidbody>().GetCopyOf(rb) as Rigidbody;
```

***

```csharp
public static T AddComponent<T>(this GameObject go, T toAdd) where T : Component
```

*This extension method copies component **toAdd** and adds it onto given gameobject.*

*Example:*

```csharp
var rb = firstGO.GetComponent<Rigidbody>();
secondGO.AddComponent(rb);
```
