T GetInDescendantsOrSelf( bool includeDisabled )

robot_2Generated
code_blocksInput

Description

The GetInDescendantsOrSelf method in the ComponentList class is used to find a component of a specified type within the current game object or any of its descendants. This method is generic and returns the first component of type T that it finds. The search can optionally include disabled components based on the includeDisabled parameter.

Usage

To use the GetInDescendantsOrSelf method, you need to specify the type of component you are looking for as the generic type parameter T. You also need to provide a boolean value for the includeDisabled parameter to indicate whether disabled components should be included in the search.

For example, if you are looking for a component of type MyComponent and you want to include disabled components in the search, you would call the method like this:

var component = componentList.GetInDescendantsOrSelf<MyComponent>(true);

Example

// Example of using GetInDescendantsOrSelf
ComponentList componentList = new ComponentList();

// Attempt to find a component of type MyComponent in the current game object or its descendants
// Include disabled components in the search
MyComponent myComponent = componentList.GetInDescendantsOrSelf<MyComponent>(true);

if (myComponent != null)
{
    // Component found, proceed with logic
}
else
{
    // Component not found, handle accordingly
}