Rucksack is a dependency injection solution for Unity. Using the Service Locator patterns built into Unity, Rucksack doesn’t re-invent the wheel.
We’ve used various dependency injection frameworks in and out of Unity. All of them have been cumbersome, requiring custom scripts and scene game objects that just obfuscate the problem.
Rucksack resolves the problem created by so many other DI framework by providing an easy to use attribute API. The attributes trigger the use of the GetComponent(s) service locator methods provided by Unity to resolve your game object dependencies for you.
Not only does Rucksack resolve your dependencies, but it has runtime checking to make sure the dependencies you are attempting to resolve don’t go unnoticed. If however you have an optional dependency, you can disable the runtime validation for that dependency.
Rucksack is currently built to support Windows x86 and x86_x64 with Linux and MacOS support coming soon.
Inline Field and Property injection.
Resolve custom components and built-in Unity components.
Legible and easy to use Api.
No special Scene game objects or scripts required.
Set readonly properties.
Dependency injection from self, parent(s), and children.
Resolve a single component or a collection of components.
Runtime dependency validation.
Quick Start and Scripting documentation.
Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we have recommended. While clicking these links won't cost you any money, they will help me fund my development projects while recommending great assets!