Zenject is a lightweight dependency injection framework built specifically to target Unity. It can be used to turn the code base of your Unity application into a collection of loosely-coupled parts with highly segmented responsibilities. Zenject can then glue the parts together in many different configurations to allow you to easily write, re-use, refactor and test your code in a scalable and extremely flexible way.
For more details as well as a detailed tutorial, see the github page here.
Tested on the following platforms:
PC/Mac/Linux, iOS, Android, WP8, Webplayer and WebGL
Key Features:
- Injection into normal C# classes or MonoBehaviours
- Constructor injection (can tag constructor if there are multiple)
- Field injection
- Property injection
- Method injection (for methods marked with [Inject] attribute)
- Conditional binding (eg. by type, by name, by parent type, etc.)
- Optional Dependencies
- Support for creating objects after initialization using factories
- Built-in support for memory pools
- Support for global, project-wide dependencies to apply to all scenes
- Nested Containers aka Sub-Containers (allowing to create discrete 'islands' of dependencies using 'Facade' classes)
- Injection across different Unity scenes to pass information from one scene to the next
- Scene parenting, to allow one scene to inherit the dependencies from another
- Convention based binding, based on class name, namespace, or any other criteria
- Ability to validate object graphs at editor time for quicker iteration (including dynamic object graphs created via factories)
- Automatic binding on components in the scene using the `ZenjectBinding` component
- Just-in-time resolving using the Lazy<> construct
- Auto-Mocking using the Moq library