Method GetOrAddComponent
| Edit this page View SourceGetOrAddComponent<T>(GameObject)
Returns the component of Type type. If one doesn't already exist on the GameObject it will be added.
Declaration
public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | gameObject | The GameObject this Component is attached to. |
Returns
| Type | Description |
|---|---|
| T | Component |
Type Parameters
| Name | Description |
|---|---|
| T | The type of Component to return. |
Remarks
Source: https://wiki.unity3d.com/index.php/GetOrAddComponent