Adds a new component of type T
to the GameObject
. The component can be optionally started in an enabled state.
Adds a new component of type T
to the GameObject
. The component can be optionally started in an enabled state.
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