T AddComponent( bool startEnabled )

robot_2Generated
code_blocksInput

Description

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.

Usage

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

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