# GetRootGameObjects

> Returns all the root game objects in the Scene.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.SceneManagement](/engine/6000.5/script-reference/unityengine/scenemanagement.md)
* **Assembly:** UnityEngine.CoreModule

## GetRootGameObjects()

Returns all the root game objects in the Scene.

```csharp
public GameObject[] GetRootGameObjects()
```

### Returns

| Type                                                                        | Description               |
| --------------------------------------------------------------------------- | ------------------------- |
| [GameObject\[\]](/engine/6000.5/script-reference/unityengine/gameobject.md) | An array of game objects. |

## GetRootGameObjects(List\<GameObject>)

Returns all the root game objects in the Scene.

```csharp
public void GetRootGameObjects(List<GameObject> rootGameObjects)
```

### Parameters

**** (\[List\<GameObject>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): A list which is used to return the root game objects.

### Remarks

Please make sure the list capacity is bigger than Scene.rootCount, then Unity will not allocate memory internally.
