The GetComponents<T>
method retrieves all components of type T
attached to the GameObject
. This method can include components that are currently disabled, based on the includeDisabled
parameter.
The GetComponents<T>
method retrieves all components of type T
attached to the GameObject
. This method can include components that are currently disabled, based on the includeDisabled
parameter.
To use this method, call it on an instance of GameObject
and specify whether you want to include disabled components in the results by passing a boolean value to the includeDisabled
parameter.
// Example of using GetComponents<T> to retrieve all components of a specific type GameObject myGameObject = new GameObject(); // Retrieve all components of type MyComponent, including disabled ones IEnumerable<MyComponent> components = myGameObject.GetComponents<MyComponent>(true); foreach (var component in components) { // Perform operations with each component component.DoSomething(); }