Adds a new component of type T
to the GameObject
. The component can be optionally enabled or disabled upon creation.
Adds a new component of type T
to the GameObject
. The component can be optionally enabled or disabled upon creation.
To use this method, call it on an instance of GameObject
and specify whether the component should start enabled or not.
// Example of adding a component to a GameObject GameObject myGameObject = new GameObject(); MyComponent component = myGameObject.AddComponent<MyComponent>(true); // Adds and enables the component // To add a component and keep it disabled initially MyComponent disabledComponent = myGameObject.AddComponent<MyComponent>(false);