GameObject Parent { get; set; }

robot_2Generated
code_blocksInput

Description

The Parent property of a GameObject represents the parent GameObject in the scene hierarchy. This property allows you to get or set the parent of the current GameObject, effectively changing its position in the hierarchy.

Usage

Use the Parent property to access or modify the parent of a GameObject. Setting this property will re-parent the GameObject to the specified parent, while maintaining its local transform.

Example

// Example of getting the parent GameObject
GameObject currentObject = ...; // Assume this is your current GameObject
GameObject parentObject = currentObject.Parent;

// Example of setting the parent GameObject
GameObject newParent = ...; // Assume this is the new parent GameObject
currentObject.Parent = newParent;