GameObject Parent { get; set; }

book_4_sparkGenerated
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, effectively changing its position in the hierarchy.

Usage

To access the parent of a GameObject, simply use the Parent property. You can also set this property to change the parent of the GameObject.

Example

// Accessing the parent GameObject
GameObject parent = myGameObject.Parent;

// Setting a new parent for the GameObject
myGameObject.Parent = newParentGameObject;