T AddComponent( bool startEnabled )

robot_2Generated
code_blocksInput

Description

Adds a new component of type T to the GameObject. The component can be optionally enabled or disabled upon creation.

Usage

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

Example

// 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);