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

Use this method to dynamically add a component to a GameObject at runtime. The startEnabled parameter determines whether the component should be enabled immediately upon creation.

Example

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