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 object, 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();

// Set parentObject as the parent of childObject
childObject.SetParent(parentObject, true);

// Check if parentObject is an ancestor of childObject
bool isAncestor = childObject.IsAncestor(parentObject);

// Output: true
Debug.Log(isAncestor);