The IsDescendant
method determines if a specified GameObject
is a descendant of the current GameObject
. A descendant is any object that is a child, grandchild, or further down the hierarchy of the current object.
The IsDescendant
method determines if a specified GameObject
is a descendant of the current GameObject
. A descendant is any object that is a child, grandchild, or further down the hierarchy of the current object.
To use the IsDescendant
method, call it on a GameObject
instance and pass another GameObject
as the parameter. The method will return true
if the passed GameObject
is a descendant of the current GameObject
, otherwise it will return false
.
// Example usage of IsDescendant method GameObject parentObject = new GameObject(); GameObject childObject = new GameObject(); childObject.SetParent(parentObject, true); bool isDescendant = parentObject.IsDescendant(childObject); // isDescendant will be true because childObject is a direct child of parentObject.