GameObject Parent { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Parent property of the GameTransform class represents the parent GameObject of the current transform. This property allows you to get or set the parent object, which is useful for managing hierarchical relationships between game objects in a scene.

Usage

To use the Parent property, you can access it directly from an instance of GameTransform. You can assign a new GameObject to it to change the parent, or retrieve the current parent GameObject by simply accessing the property.

Example

// Example of setting the Parent property
GameObject childObject = new GameObject();
GameObject parentObject = new GameObject();

// Assuming childObject has a GameTransform component
childObject.Transform.Parent = parentObject;

// Example of getting the Parent property
GameObject currentParent = childObject.Transform.Parent;
if (currentParent != null)
{
    // Do something with the parent
}