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 access or modify the parent of the current GameObject, enabling you to change its position in the hierarchy or retrieve its parent for further operations.

Usage

Use the Parent property to get or set the parent of a GameObject. Setting this property will re-parent the GameObject to the specified parent, affecting its transform relative to the new parent.

Example

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

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