7
\$\begingroup\$

I am semi-experienced .NET developer who has just began working with Unity. I am trying to decide on how to make IoC work in Unity 4.X ( I have not yet tested anything), and I wonder what are the good ways of achieving it.

This post and its answers states that Ninject won't work with Unity, however it is old. Is it still true? If yes, what are other means of achieving IoC in Unity ?

Edit 1 : I am targeting mainly Windows platform. So I don't need platform interoperability, I just need it to work.

\$\endgroup\$
  • \$\begingroup\$ IIRC Ninject works fine in Mono, so you should be able to use it as a service locator at least. You won't be able to do dependency injection with the classes that are instantiated by Unity, however. \$\endgroup\$ – BlueRaja - Danny Pflughoeft Jun 3 '14 at 20:26
5
\$\begingroup\$

You probably want to look at StrangeIOC.

http://strangeioc.github.io/strangeioc/

It's meant for Unity. The project has been under active development for quite some time, and I keep meaning to check it out, but as of yet I haven't so I can't give you the personal recommendation. But it sounds like exactly like what you want.

\$\endgroup\$
  • \$\begingroup\$ This is definitely what you want. I've been using it since its release (essentially) and it's very well put together with great documentation. I honestly can't see myself developing a game in Unity without it. \$\endgroup\$ – Cooper Jun 4 '14 at 18:10
  • \$\begingroup\$ Thanks a lot! That is something that so far has exceeded my expectations :) \$\endgroup\$ – actionjezus6 Jun 4 '14 at 18:11
0
\$\begingroup\$

I don't know, but nobody did managed to run it under unity: http://forum.unity3d.com/threads/ios-dependency-injection-framework-suggestions.119909/ but can be very outdated. Nonetheless, try to post your question to UnityAnswers, where will you get more likely a proper answer.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.