ssannandeji / Zenject-2019

Dependency Injection Framework for Unity3D
MIT License
2.53k stars 363 forks source link

Project Context does not work without scene context #607

Closed dharness closed 5 years ago

dharness commented 5 years ago
  1. Create a Project context
  2. Attach an installer
  3. Run build

The project context is not picked up.

  1. Create a Project context
  2. Attach an installer
  3. Create an empty scene context, no installers
  4. Run build

The project context IS picked up.

I think this should be considered an error. At the very least it's confusing. If this is intentional I don't believe this behaviour is described in the docs anywhere.

Thanks!

sceeter89 commented 5 years ago

Actually it is expected behaviour specified in documentation. Take a look at https://github.com/modesttree/Zenject

Scroll to "Global Bindings Using Project Context" and you will find following text:

Then, when you start any scene that contains a SceneContext, your ProjectContext object will always be initialized first. All the installers you add here will be executed and the bindings that you add within them will be available for use in all scenes within your project. The ProjectContext game object is set as DontDestroyOnLoad so it will not be destroyed when changing scenes.

dharness commented 5 years ago

Well would you look at that, thanks!