Init(args) is a seamlessly integrated and type safe framework for providing your Components and ScriptableObjects with their dependencies.



Have you ever wished you could just call Add Component with arguments like this:

  Player player = gameObject.AddComponent<Player, IInputManager>(inputManager);
Or maybe you’ve sometimes wished you could Instantiate with arguments like so:
  Player player = playerPrefab.Instantiate(inputManager);

And wouldn’t it be great if you could create ScriptableObject instances with arguments as well:

  DialogueAsset dialogue = Create.Instance<DialogueAsset, Guid>(id);

This is precisely what Init(args) let’s you do! All you need to do is derive your class from one of the generic MonoBehaviour<T…> base classes, and you’ll be able to receive upto five arguments in your Init function.

In cases where you can’t derive from a base class you can also implement the IInitializable<T> interface and manually handle receiving the arguments with a single line of code (see the InitArgs section of the documentation for more details).


You can learn more about Init(args) from its online documentation.