Inject Classes
Use Zenject Dependency Injection
Last updated
Was this helpful?
Use Zenject Dependency Injection
Last updated
Was this helpful?
There are different ways to inject classes using dependency injection. Zenject provides constructor, field, property, and method injection.
It is recommended to only use Constructor and Method Injection.
Most of your scripts will probably inherit form MonoBehaviour
so you will not be able to use constructor injection. If your class is a service or helper class that does not inherit MonoBehaviour
then you can use constructor injection.
Zenject dependency Injection will automatically provide an instance of EasyEvents into the DependencyInjectionExample
class
Most of your scripts will probably inherit form MonoBehaviour
so you will not be able to use constructor injection. In that case you will need to use Method injection. There 2 ways that you can use Method Injection.