title: How to bind a list of non-MonoBehaviour objects to manager class using Zenject
body: <p>I am using Zenject for dependency injection in my game, and I am in an impasse.</p>
  
  <p>Let me describe my current setup:</p>
  
  <p>I have several characters with their own <code>GameObjectContext</code> and <code>CharacterInstaller</code> responsible for injecting a <code>CharacterController</code> into a <code>CharacterPresenter</code>.</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class CharacterInstaller : MonoInstaller&lt;CharacterInstaller&gt;
  {
      public override void InstallBindings()
      {
          Container.BindInterfacesAndSelfTo&lt;CharacterInstaller&gt;().AsSingle().NonLazy();
      }
  }
  </code></pre>
  
  <pre class="lang-cs prettyprint-override"><code>// PLAIN C# class
  public class CharacterController : &lt;some_interfaces&gt;
  {
      public void Foo()
      {
          // ...
      }
  }
  </code></pre>
  
  <pre class="lang-cs prettyprint-override"><code>public class CharacterPresenter : MonoBehaviour
  {
      private CharacterController characterController;
  
      [Inject]
      public void InjectDependencies( CharacterController characterController )
      {
          this.characterController = characterController;
      }
  
      public void Foo() =&gt; characterController.Foo();
  }
  </code></pre>
  
  <hr>
  
  <p>What I would like to do is to also inject all the instances of the <code>CharacterController</code> class into a "Manager" class using <a href="https://github.com/modesttree/Zenject#list-bindings" rel="nofollow noreferrer">List Bindings</a>. This manager is not a parent of my characters, and I may need several managers.</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class CharactersManager
  {
      private List&lt;Character&gt; characters;
  
      public CharactersManager( List&lt;Character&gt; characters)
      {
          this.characters = characters;
      }
  
      public void MakeCharactersDoSomething()
      {
          foreach ( Character character in characters)
              character.Foo();
      }
  }
  </code></pre>
  
  <p>The closer things I found to solve my problem were:</p>
  
  <p>• Attach a <code>ZenjectBinding</code> component to my Character and specify the context I need.<br>
  → Can't work because <code>CharacterController</code> is a plain C# class and the <code>ZenjectBinding</code> only binds components</p>
  
  <p>• Declare a <code>Context</code> in the <code>CharacterInstaller</code> and call <code>OtherContext.Container.Bind...</code><br>
  → Fails because <code>OtherContext.Container</code> is null</p>
  
  <p>• Call <code>Container.Bind&lt;CharacterController&gt;().FromComponentsInHierarchy()</code> in my manager installer<br>
  → Does not work because <code>CharacterController</code> is not a component</p>
  
  <p>• Using a factory<br>
  → I can't use it since my objects are meant to be placed at edit time in the editor</p>
  
  <p>• Using <code>Container.ParentContainers</code> in my <code>CharacterInstaller</code><br>
  → Can't use it because my manager is not a parent container of my <code>CharacterInstaller.Container</code></p>
  
  <p>I am open to suggestions, maybe a refactoring of my setup if needed. Thanks in advance</p>