Init(args)
Scripting Reference
Loading...
Searching...
No Matches
Sisus.Init.MonoBehaviour< TArgument > Class Template Referenceabstract

Description

A base class for MonoBehaviours that can be instantiated or added to a GameObject with an argument passed to the Init method of the created instance.

If the object depends on an object that has been registered as service using the ServiceAttribute, then it will be able to receive the service in its Init method automatically during its initialization.

If the component is part of a scene or a prefab, and depends on a class that doesn't have the ServiceAttribute, then an Initializer<TComponent, TArgument> can be used to specify its initialization argument.

Instances of classes inheriting from MonoBehaviour<TArgument> receive the argument via the Init method where it can be assigned to a member field or property.

Template Parameters
TArgumentType of the argument received in the Init method.
Inheritance diagram for Sisus.Init.MonoBehaviour< TArgument >:
Sisus.Init.MonoBehaviourBase Sisus.Init.IInitializable< TArgument > Sisus.Init.IInitializable Sisus.Init.IArgs< TArgument > Sisus.Init.IOneArgument Sisus.Init.IFirstArgument< TFirstArgument >

Protected Member Functions

void Init (TArgument argument)
 Provides the Component with the argument object that it depends on.
 
virtual void OnReset ()
 Reset state to default values.
 
override bool Init (Context context)
 Requests the object to try and acquire the object that it depends on and initialize itself.
 
- Protected Member Functions inherited from Sisus.Init.MonoBehaviourBase
virtual void OnAwake ()
 OnAwake is called when the script instance is being loaded during the Awake event after the InitInternal function has finished.
 
bool Init (Context context)
 Requests the object to try and acquire all the objects that it depends on and initialize itself.
 
void ThrowIfNull< TArgument > (TArgument argument)
 Checks if the argument is null and throws an System.ArgumentNullException if it is.
 
void AssertNotNull< TArgument > (TArgument argument)
 Checks if the argument is null and logs an assertion message to the console if it is.
 
virtual void ValidateArgument< TArgument > (TArgument argument)
 Method that can be overridden and used to validate the initialization arguments that were received by this object.
 
virtual void ValidateArguments< TFirstArgument, TSecondArgument > (TFirstArgument firstArgument, TSecondArgument secondArgument)
 Method that can be overridden and used to validate the initialization arguments that were received by this object.
 
virtual void ValidateArguments< TFirstArgument, TSecondArgument, TThirdArgument > (TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument)
 Method that can be overridden and used to validate the initialization arguments that were received by this object.
 
virtual void ValidateArguments< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument > (TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument)
 Method that can be overridden and used to validate the initialization arguments that were received by this object.
 
virtual void ValidateArguments< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument > (TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument)
 Method that can be overridden and used to validate the initialization arguments that were received by this object.
 
virtual void ValidateArguments< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument > (TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument)
 Method that can be overridden and used to validate the initialization arguments that were received by this object.
 
virtual void ValidateArguments< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument, TSeventhArgument > (TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument, TSeventhArgument seventhArgument)
 Method that can be overridden and used to validate the initialization arguments that were received by this object.
 
virtual void ValidateArguments< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument, TSeventhArgument, TEighthArgument > (TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument, TSeventhArgument seventhArgument, TEighthArgument eighthArgument)
 Method that can be overridden and used to validate the initialization arguments that were received by this object.
 
virtual void ValidateArguments< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument, TSeventhArgument, TEighthArgument, TNinthArgument > (TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument, TSeventhArgument seventhArgument, TEighthArgument eighthArgument, TNinthArgument ninthArgument)
 Method that can be overridden and used to validate the initialization arguments that were received by this object.
 
virtual void ValidateArguments< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument, TSeventhArgument, TEighthArgument, TNinthArgument, TTenthArgument > (TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument, TSeventhArgument seventhArgument, TEighthArgument eighthArgument, TNinthArgument ninthArgument, TTenthArgument tenthArgument)
 Method that can be overridden and used to validate the initialization arguments that were received by this object.
 
virtual void ValidateArguments< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument, TSeventhArgument, TEighthArgument, TNinthArgument, TTenthArgument, TEleventhArgument > (TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument, TSeventhArgument seventhArgument, TEighthArgument eighthArgument, TNinthArgument ninthArgument, TTenthArgument tenthArgument, TEleventhArgument eleventhArgument)
 Method that can be overridden and used to validate the initialization arguments that were received by this object.
 
virtual void ValidateArguments< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument, TSeventhArgument, TEighthArgument, TNinthArgument, TTenthArgument, TEleventhArgument, TTwelfthArgument > (TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument, TSeventhArgument seventhArgument, TEighthArgument eighthArgument, TNinthArgument ninthArgument, TTenthArgument tenthArgument, TEleventhArgument eleventhArgument, TTwelfthArgument twelfthArgument)
 Method that can be overridden and used to validate the initialization arguments that were received by this object.
 
void HandleValidate< TArgument > (Context context, TArgument argument)
 Handles validating the initialization argument that was received by this component, if Play Mode is active, and Null Argument Guard has been enabled for the component.
 
void HandleValidate< TFirstArgument, TSecondArgument > (Context context, TFirstArgument firstArgument, TSecondArgument secondArgument)
 Handles validating the initialization arguments that were received by this component, if Play Mode is active, and Null Argument Guard has been enabled for the component.
 
void HandleValidate< TFirstArgument, TSecondArgument, TThirdArgument > (Context context, TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument)
 Handles validating the initialization arguments that were received by this component, if Play Mode is active, and Null Argument Guard has been enabled for the component.
 
void HandleValidate< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument > (Context context, TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument)
 Handles validating the initialization arguments that were received by this component, if Play Mode is active, and Null Argument Guard has been enabled for the component.
 
void HandleValidate< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument > (Context context, TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument)
 Handles validating the initialization arguments that were received by this component, if Play Mode is active, and Null Argument Guard has been enabled for the component.
 
void HandleValidate< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument > (Context context, TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument)
 Handles validating the initialization arguments that were received by this component, if Play Mode is active, and Null Argument Guard has been enabled for the component.
 
void HandleValidate< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument, TSeventhArgument > (Context context, TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument, TSeventhArgument seventhArgument)
 Handles validating the initialization arguments that were received by this component, if Play Mode is active, and Null Argument Guard has been enabled for the component.
 
void HandleValidate< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument, TSeventhArgument, TEighthArgument > (Context context, TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument, TSeventhArgument seventhArgument, TEighthArgument eighthArgument)
 Handles validating the initialization arguments that were received by this component, if Play Mode is active, and Null Argument Guard has been enabled for the component.
 
void HandleValidate< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument, TSeventhArgument, TEighthArgument, TNinthArgument > (Context context, TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument, TSeventhArgument seventhArgument, TEighthArgument eighthArgument, TNinthArgument ninthArgument)
 Handles validating the initialization arguments that were received by this component, if Play Mode is active, and Null Argument Guard has been enabled for the component.
 
void HandleValidate< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument, TSeventhArgument, TEighthArgument, TNinthArgument, TTenthArgument > (Context context, TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument, TSeventhArgument seventhArgument, TEighthArgument eighthArgument, TNinthArgument ninthArgument, TTenthArgument tenthArgument)
 Handles validating the initialization arguments that were received by this component, if Play Mode is active, and Null Argument Guard has been enabled for the component.
 
void HandleValidate< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument, TSeventhArgument, TEighthArgument, TNinthArgument, TTenthArgument, TEleventhArgument > (Context context, TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument, TSeventhArgument seventhArgument, TEighthArgument eighthArgument, TNinthArgument ninthArgument, TTenthArgument tenthArgument, TEleventhArgument eleventhArgument)
 Handles validating the initialization arguments that were received by this component, if Play Mode is active, and Null Argument Guard has been enabled for the component.
 
void HandleValidate< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument, TSixthArgument, TSeventhArgument, TEighthArgument, TNinthArgument, TTenthArgument, TEleventhArgument, TTwelfthArgument > (Context context, TFirstArgument firstArgument, TSecondArgument secondArgument, TThirdArgument thirdArgument, TFourthArgument fourthArgument, TFifthArgument fifthArgument, TSixthArgument sixthArgument, TSeventhArgument seventhArgument, TEighthArgument eighthArgument, TNinthArgument ninthArgument, TTenthArgument tenthArgument, TEleventhArgument eleventhArgument, TTwelfthArgument twelfthArgument)
 Handles validating the initialization arguments that were received by this component, if Play Mode is active, and Null Argument Guard has been enabled for the component.
 

Properties

TArgument this[[DisallowNull] string memberName [set]
 Assigns an argument received during initialization to a field or property by the memberName given name.
 
- Properties inherited from Sisus.Init.MonoBehaviourBase
static NullExtensions.NullComparer Null [get]
 A value against which any object can be compared to determine whether or not it is null or an UnityEngine.Object which has been destroyed.
 
static NullExtensions.NullOrInactiveComparer NullOrInactive [get]
 A value against which any object can be compared to determine whether or not it is null or an UnityEngine.Object which is inactive or has been destroyed.