bool IsAncestor( GameObject ancestor )

robot_2Generated
code_blocksInput

Description

The IsAncestor method determines if a specified GameObject is an ancestor of the current GameObject. An ancestor is any GameObject that exists in the hierarchy above the current GameObject, including its direct parent and any higher-level parents.

Usage

To use the IsAncestor method, call it on a GameObject instance and pass another GameObject as the parameter. The method will return true if the specified GameObject is an ancestor of the current GameObject, otherwise it will return false.

Example

// Example usage of IsAncestor method
GameObject childObject = new GameObject();
GameObject parentObject = new GameObject();

// Assume parentObject is set as the parent of childObject
childObject.SetParent(parentObject, true);

bool isAncestor = childObject.IsAncestor(parentObject);
// isAncestor will be true because parentObject is the parent of childObject