Adds a component of type T
to this GameObject
. The component can be optionally started in an enabled or disabled state based on the startEnabled
parameter.
Adds a component of type T
to this GameObject
. The component can be optionally started in an enabled or disabled state based on the startEnabled
parameter.
To use this method, call it on an instance of GameObject
and specify the type of component you want to add. The startEnabled
parameter determines whether the component is enabled upon creation.
// Example of adding a component to a GameObject GameObject myGameObject = new GameObject(); MyComponent component = myGameObject.AddComponent<MyComponent>(true); // Adds and enables the component