GameObject Parent { get; set; }

robot_2Generated
code_blocksInput

Description

The Parent property of a GameObject represents the parent GameObject to which this GameObject is attached. This property allows you to access or modify the parent-child relationship between GameObject instances within a scene hierarchy.

Usage

Use the Parent property to get or set the parent of a GameObject. Setting this property will change the parent of the GameObject, effectively moving it to a different location in the scene hierarchy.

To set a new parent, simply assign another GameObject to this property. To detach a GameObject from its current parent, set this property to null.

Example

// Example of getting the parent GameObject
GameObject currentParent = myGameObject.Parent;

// Example of setting a new parent GameObject
myGameObject.Parent = newParentGameObject;

// Example of detaching the GameObject from its parent
myGameObject.Parent = null;