List<GameObject> Children { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Children property of a GameObject provides access to a list of all child GameObject instances that are directly parented to this GameObject. This property is useful for iterating over or managing the hierarchy of objects within a scene.

Usage

Use the Children property to access or manipulate the child objects of a GameObject. This property returns a List<GameObject>, allowing you to perform operations such as adding, removing, or iterating over child objects.

Example

// Example of accessing the Children property
GameObject parentObject = new GameObject();

// Add a child GameObject
GameObject childObject = new GameObject();
parentObject.Children.Add(childObject);

// Iterate over all children
foreach (GameObject child in parentObject.Children)
{
    // Perform operations on each child
    child.Name = "Child of " + parentObject.Name;
}