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, directly or indirectly, than the current GameObject
.
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, directly or indirectly, than the current GameObject
.
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 passed GameObject
is an ancestor of the instance, 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 an ancestor of childObject