Dependency Injection for Unity Statics
Dan Violet Sagmiller
$0.0
(no ratings)
Date |
Price |
---|---|
日時 |
価格($) |
03/19(2018) |
0.0 |
11/26(2024) |
0.0 |
Jump AssetStore
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.