Method GetOrAddComponent
GetOrAddComponent<T>(GameObject, bool)
Get a typed component from the gameobject or add it if it doesn't already exist.
Declaration
public static T GetOrAddComponent<T>(GameObject go, bool insertFirst = false) where T : Component
Parameters
Type | Name | Description |
---|---|---|
GameObject | go | The gameobject to get/add the component from/to. |
bool | insertFirst | Whether we insert the component as the first on the list for the gameobject. |
Returns
Type | Description |
---|---|
T | The component that we got or added. |
Type Parameters
Name | Description |
---|---|
T | The component type. |