Retrieves a component of type T
from the GameObject
. This method allows you to specify whether to include components that are currently disabled.
Retrieves a component of type T
from the GameObject
. This method allows you to specify whether to include components that are currently disabled.
Use this method when you need to access a specific component attached to a GameObject
. You can choose to include disabled components in the search by setting the includeDisabled
parameter to true
.
// Example of using GetComponent to retrieve a component var myComponent = myGameObject.GetComponent<MyComponentType>(includeDisabled: false); if (myComponent != null) { // Use the component myComponent.DoSomething(); }