Unity3d field dependency injection

By admin | 26 July 2016

I just added Unity3dInject to github. It's a very lightweight non intrusive field dependency injection solution for Unity3D. Ir works with both poco classes and MonoBehaviours.

Setting up a class for dependencies is done by setting a [Dependency]-attribute on the dependency field. The injection is done by DependencySetter components with respect to the hierarchy in the SceneGraph. Doing it like this is makes it intuitive to understand which dependency container will be used for each object. There is also a global dependency container that will be used as a last resort. Usually you will put objects like your GameStateManager or SceneManager here.

You can try it out on github.


No Comments

Add a Comment