Re:Basic Concepts in Unity for Software Engineers
by andypants on Monday October 12, 2020 @09:36AM
(#24754189)
You can use unity-aware dependency injection with extenject: https://github.com/svermeulen/Extenject
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.