AddComponent< TComponent, TArgument > |
AddComponent< TComponent, TArgument > |
AddComponent< TComponent, TFirstArgument, TSecondArgument > |
AddComponent< TComponent, TFirstArgument, TSecondArgument > |
AddComponent< TComponent, TFirstArgument, TSecondArgument, TThirdArgument > |
AddComponent< TComponent, TFirstArgument, TSecondArgument, TThirdArgument > |
AddComponent< TComponent, TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument > |
AddComponent< TComponent, TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument > |
AddComponent< TComponent, TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument > |
AddComponent< TComponent, TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument > |
Get< T > |
|
◆ AddComponent< TComponent, TArgument >() [1/2]
static TComponent Sisus.Init.GameObjectExtensions.AddComponent< TComponent, TArgument > |
( |
[NotNull] this GameObject |
gameObject, |
|
|
TArgument |
argument |
|
) |
| |
|
static |
Adds a component of type TComponent to the gameObject and initializes the component using the provided argument .
The argument should either be received by the added component during its initialization (such during the Awake event function or in the constructor) or if the component class implements the IInitializable<TArgument> interface the argument can be provided using the Init function immediately after initialization has finished (before the Start event function).
For classes deriving from MonoBehaviour<TArgument> the latter method will be used in cases where the gameObject is inactive, while if the the gameObject is inactive the arguments will be received during the Awake event function.
- Template Parameters
-
TComponent | Type of the component to add. |
TArgument | Type of the argument passed to the component's Init function. |
- Parameters
-
gameObject | The GameObject to which the component is added. |
argument | The argument passed to the component's Init function. |
- Returns
- The added component.
- Exceptions
-
- Type Constraints
-
TComponent | : | MonoBehaviour | |
TComponent | : | IArgs<TArgument> | |
|