3 ms·
The Unity example code is laughably bad. But don't use dependency injection. Unity's Scene/Prefab load/instantiation is already a form of DI. Using another ca
by jayd16 6y ago
The Unity example code is laughably bad.
But don't use dependency injection. Unity's Scene/Prefab load/instantiation is already a form of DI. Using another causes issues with juggling multiple lifecycles.
You also lose the ability for Unity to prefetch assets because Unity can't inspect the dependency graph if it's not done through the asset system. Instead you hit situations where you're loading several objects and running DI code over several frames when unity could have loaded everything at once.
- andypants 6y agoYou can use unity-aware dependency injection with extenject: https://github.com/svermeulen/Extenject https://github.com/svermeulen/Extenject