Retrieves a component of type T
from the current GameObject
or any of its descendant GameObject
s. This method allows you to specify whether to include components that are disabled and whether to include the current GameObject
in the search.
Retrieves a component of type T
from the current GameObject
or any of its descendant GameObject
s. This method allows you to specify whether to include components that are disabled and whether to include the current GameObject
in the search.
Use this method when you need to find a specific component type within a GameObject
hierarchy. You can control the search behavior using the includeDisabled
and includeSelf
parameters:
includeDisabled
: Set to true
to include components that are disabled in the search; otherwise, set to false
.includeSelf
: Set to true
to include the current GameObject
in the search; otherwise, set to false
.// Example of using GetComponentInChildren var myComponent = myGameObject.GetComponentInChildren<MyComponentType>(includeDisabled: false, includeSelf: true); if (myComponent != null) { // Do something with the component }