01. What Is Init(args)

  01. Introduction No Comments

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

Main Features

  • Add Component with arguments.
  • Instantiate with arguments.
  • Create Instance with arguments.
  • new GameObject with arguments.
  • Service framework (a powerful alternative to Singletons).
  • Wrapper system (attach plain old class objects to GameObjects).
  • Auto-Initialization support.
  • Assigning to read-only fields and properties.
  • Type safety thanks to use of generics.
  • Reflection-free dependency injection.


Did you ever wish 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 six 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).

Leave a Reply

Your email address will not be published. Required fields are marked *