T GetInAncestors( bool includeDisabled )

robot_2Generated
code_blocksInput

Description

The GetInAncestors method is used to find a component of type T on the ancestors of the current game object. This method traverses up the hierarchy of game objects, starting from the parent of the current game object, to locate the specified component type.

Usage

To use the GetInAncestors method, call it on an instance of ComponentList and specify whether to include disabled components in the search by passing a boolean value to the includeDisabled parameter.

Example

// Example of using GetInAncestors to find a component of type MyComponent
ComponentList componentList = myGameObject.GetComponentList();
MyComponent component = componentList.GetInAncestors<MyComponent>(includeDisabled: true);

if (component != null)
{
    // Component found, perform operations on it
}
else
{
    // Component not found in ancestors
}