Null Argument Guard
The Null Argument Guard is a feature that can automatically inform you about missing Init arguments that any of your components might have. The feature consists of three distinct parts:
- Inspector Warnings – Warnings shown in the Editor when you view a component containing missing Init arguments in the Inspector Window.
- Edit Mode Warnings – Warnings logged into the Console Window when components with missing Init arguments are loaded in Edit Mode.
- Runtime Exceptions – Exceptions thrown when components with missing Init arguments are initialized at runtime.
Inspector Warnings
An Init section listing all the services that a client depends is drawn in the Inspector for all components that derive from MonoBehaviour<T…>, implement IInitializable<T…>, or have an Initializer attached to them.
When one or more of the Init arguments that one such client component depends on are missing, the Null Argument Guard will by default display a warning about it, and highlight the relevant fields in a yellow color.

Edit Mode Warnings
When an initializer is attached to a component, you can also have warnings be printed to the Console Window in Edit Mode if the component is loaded with some of its Init arguments being missing.

Configuring Edit Mode Warnings
Both Inspector Warnings and Edit Mode Warnings are controlled using the same settings.
Null Argument Guard Icon
You can toggle Edit Mode Warnings on and off using the Null Argument Guard icon found in the top-right corner of the Init section.

If an Initializer is attached to the component, then the toggling this option will only affect this one particular client. This is because Initializers are used to configure the Init arguments of one particular instance.
If the component does not have an Initializer attached, then the toggling this option affect all instances of the component – except for those that might have an Initializer attached. In this case the setting will saved in the .meta data of the component whenever possible (if this is not possible for whatever reason, EditorPrefs is used as fallback).
[Init] Attribute
It is also possible to add the [Init] attribute to a class and assign None or RuntimeException to its NullArgumentGuard property to the disable Edit Mode Warnings for all instances of the class by default.
[Init(NullArgumentGuard = NullArgumentGuard.RuntimeException)]
class Player : MonoBehaviour<InputManager, GameManager>
{
...
Best Practices
Edit Mode Warnings can be very useful for helping make sure you catch any broken references and improperly registered services as soon as possible.
If you only register globally available services using the [Service] attribute, and constrain the availability of local services to the hierarchies of the scenes and prefabs they are attached to, then the Inspector Warnings will almost give you accurate results.
If this fails, you can also avoid having to turn off Edit Mode Warnings entirely, by attaching an Initializer to a component, and assigning Wait For Service to the Init argument fields that depend on local services that will only become available at runtime.
Runtime Exceptions
You can also have an InvalidInitArgumentsException be automatically thrown if components that derives from MonoBehaviour<T…> or has an Initializer attached don’t receive all the Init arguments that they depend on at runtime.
Configuring Runtime Exceptions
Null Argument Guard Icon
You can toggle Runtime Exceptions on and off using the Null Argument Guard icon found in the top-right corner of the Init section.
[Init] Attribute
You can also add the [Init] attribute to a class and assign None or EditModeWarning to its NullArgumentGuard property to the disable Runtime Exceptions for all instances of the class by default.
[Init(NullArgumentGuard = NullArgumentGuard.None)]
class Player : MonoBehaviour<InputManager, GameManager>
{
...
Configuring Wait For Services
By default, client components don’t immediately throw an exception even if Runtime Exceptions are enabled and they are loaded with some of their Init arguments still being missing.
Instead, they will be disabled, and their initialization delayed for some time, to give local services that the client might depend on some time to load. Currently clients will wait for up to 3 seconds for all their Init arguments to become available before considering it a lost cause, and throwing an exception (if Runtime Exceptions are enabled).
If you would like to have all instances of a particular component class throw an exception immediately, instead of after a delay of 3 seconds, you can add the [Init] attribute to the class and assign false to the WaitForServices property.
[Init(WaitForServices = false, NullArgumentGuard = NullArgumentGuard.All)]
class Player : MonoBehaviour<InputManager, GameManager>
{
...