T AddComponent( bool startEnabled )

robot_2Generated
code_blocksInput

Description

Adds a new component of type T to the GameObject. The component can be optionally started in an enabled state.

Usage

To use this method, call it on an instance of GameObject and specify whether the component should start enabled.

Example

// Example of adding a component to a GameObject
GameObject myGameObject = new GameObject();
MyComponent component = myGameObject.AddComponent<MyComponent>(true); // Adds MyComponent and starts it enabled