Dependency Injection for Unity Statics

FREE
Publisher Dan Violet Sagmiller
File size 659.88kB
Number of files 278
Latest version 1
Latest release date 2016-07-19 08:42:24
First release date 2016-07-19 08:42:24
Supported Unity versions 2018.4.2 or higher
Static calls in Unity can make unit testing difficult to impossible. This package allows you to replace Static calls in Unity with POCO wrappers with Interfaces. This allows you to easily tie Unity into your favorite Dependency Injection Framework. Such as Zenject. Aside from the "Di" or "I" prefix on the classes and interfaces, the naming and calling is identical, allowing you replace existing code more easily.

All source code included.

Let me know of anything is missing, our getting out dated with new versions, and I'll update the package.

Example:
Assuming you want to get the width of the screen. Normally you would use
var width = Screen.Width;

Now you would call
IScreen _Screen = new DiScreen();
var width = _Screen.Width;

Future Plans:
1) To include Intellisense explanations and links.
2) I built a project that uses reflection to write this code. Once run, it still requires some cleanup. Once this is producing clean code on the fly, I'll produce a separate package, so you can automatically extract static calls out of any library.

Top Publisher Assets