IEnumerable<T> GetComponents( bool includeDisabled )

robot_2Generated
code_blocksInput

Description

The GetComponents<T> method retrieves all components of type T attached to the GameObject. This method can optionally include components that are currently disabled.

Usage

To use the GetComponents<T> method, specify the type of component you want to retrieve and whether to include disabled components. This method returns an IEnumerable<T> of the specified component type.

Example

// Example of using GetComponents to retrieve all components of a specific type
var gameObject = new GameObject();

// Retrieve all components of type MyComponent, including disabled ones
IEnumerable<MyComponent> components = gameObject.GetComponents<MyComponent>(includeDisabled: true);

foreach (var component in components)
{
    // Perform operations with each component
    component.DoSomething();
}