The IsAncestor
method determines if a specified GameObject
is an ancestor of the current GameObject
. An ancestor is any GameObject
that is higher up in the hierarchy, including direct parents and any of their parents.
The IsAncestor
method determines if a specified GameObject
is an ancestor of the current GameObject
. An ancestor is any GameObject
that is higher up in the hierarchy, including direct parents and any of their parents.
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 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