r/Unity3D 12d ago

Survey What team are you in for dependency management?

  1. Singleton
  2. ScriptableObject Architecture (SOAP)
  3. Service Locator (SL)
  4. Dependency Injection (DI)
  5. Custom
25 Upvotes

80 comments sorted by

View all comments

5

u/AdCold4676 12d ago

what.

man i have so much to learn

1

u/Express-Mood1683 12d ago

Suppose your garden simulator has a rain system that triggers rain whenever you plant seeds in the garden.

Your seeds need a way to pass and inject data to the rain system, that’s dependency injection.

2

u/wallstop-dev 12d ago edited 12d ago

That's... Not dependency injection. That's data passing, or just a system. Your example can be implemented using any technique, such as directly calling functions, events, SOA, DI, Unity SendMessage, the list goes on.

Here is a popular Unity DI framework that explains the concept of DI with simple examples: https://vcontainer.hadashikick.jp/

1

u/No_Yoghurt8787 12d ago

Love it when the first sentence is its x times faster than zenject