Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Dependency Injection

Discussion in 'Scripting' started by fau7, Aug 14, 2018.

  1. fau7

    fau7

    Joined:
    Jan 24, 2018
    Posts:
    48
    Hi guys,
    I am looking for a solution for Dependency Injection in Unity. Does anyone have an experience on AOP in Unity?
    I would be grateful for a perspective or a tip :/
    Wish everyone the best
    Cheers
    Fau
     
  2. Fido789

    Fido789

    Joined:
    Feb 26, 2013
    Posts:
    343
    There is basically only Zenject, but it works really well.
     
  3. fau7

    fau7

    Joined:
    Jan 24, 2018
    Posts:
    48
    Fido789!! Thank you so much. This is great news.
    I am downloading now. I have checked out the features. Sounds promising.

    Wow!!
    • Injection
      • Supports both normal C# classes and MonoBehaviours
      • Constructor injection
      • Field injection
      • Property injection
      • Method injection
    • Conditional binding (eg. by type, by name, etc.)
    • Optional dependencies
    • Support for creating objects after initialization using factories
    • Nested Containers aka Sub-Containers
    • Injection across different Unity scenes to pass information from one scene to the next
    • Scene parenting, to allow one scene to inherit the bindings from another
    • Support for global, project-wide bindings to add dependencies for all scenes
    • Convention based binding, based on class name, namespace, or any other criteria
    • Ability to validate object graphs at editor time (including dynamic object graphs created via factories)
    • Automatic binding on components in the scene using the ZenjectBinding component
    • Auto-Mocking using the Moq library
    • Built-in support for memory pools
    • Support for decorator pattern using decorator bindings
    • Support for automatically mapping open generic types
    • Built in support for unit test, integration tests, and scene tests
    • Just-in-time injection using the LazyInject<> construct
    Cheers Fido789 :)
     
  4. fau7

    fau7

    Joined:
    Jan 24, 2018
    Posts:
    48
    I have downloaded Zenject and right now I am trying to implement Method Injection. It's really exciting these quality frameworks in service of the community with full open source. Thank you Zenject! Thank you Fido789!!
     
  5. Fido789

    Fido789

    Joined:
    Feb 26, 2013
    Posts:
    343
    Yes, it is really nice piece of software, I am glad you like it too.
     
    fau7 likes this.