- 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 when adding components in the editor.
- Assigning to read-only fields and properties.
- Type safety thanks to use of generics.
- Reflection-free dependency injection.
HOW DOES IT WORK?
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.