Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetRootGameObjects

Returns all the root game objects in the Scene.
Read time 1 minuteLast updated 9 days ago

Definition

GetRootGameObjects()

Returns all the root game objects in the Scene.
public GameObject[] GetRootGameObjects()

Returns

Type

Description

GameObject[]An array of game objects.

GetRootGameObjects(List<GameObject>)

Returns all the root game objects in the Scene.
public void GetRootGameObjects(List<GameObject> rootGameObjects)

Parameters

rootGameObjects

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.