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, TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument >() [1/2]
static TComponent Sisus.Init.GameObjectExtensions.AddComponent< TComponent, TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument > |
( |
[NotNull] this GameObject |
gameObject, |
|
|
TFirstArgument |
firstArgument, |
|
|
TSecondArgument |
secondArgument, |
|
|
TThirdArgument |
thirdArgument, |
|
|
TFourthArgument |
fourthArgument |
|
) |
| |
|
static |
Adds a component of type TComponent to the gameObject and initializes the component using the provided arguments.
Arguments 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<TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument> interface the arguments can be provided using the Init function immediately after initialization has finished (before the Start event function).
For classes deriving from MonoBehaviour<TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument> 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. |
TFirstArgument | Type of the first argument passed to the component's Init function. |
TSecondArgument | Type of the second argument passed to the component's Init function. |
TThirdArgument | Type of third argument which is passed to the component's Init function. |
TFourthArgument | Type of fourth argument which is passed to the component's Init function. |
- Parameters
-
gameObject | The GameObject to which the component is added. |
firstArgument | The first argument passed to the component's Init function. |
secondArgument | The second argument passed to the component's Init function. |
thirdArgument | The third argument passed to the component's Init function. |
fourthArgument | The fourth argument passed to the component's Init function. |
- Returns
- The added component.
- Exceptions
-
- Type Constraints
-
TComponent | : | MonoBehaviour | |
TComponent | : | IArgs | |
TComponent | : | TFirstArgument | |
TComponent | : | TSecondArgument | |
TComponent | : | TThirdArgument | |
TComponent | : | TFourthArgument | |
|