VContainer icon indicating copy to clipboard operation
VContainer copied to clipboard

Scene based scopes not running after scene load

Open adamsingle opened this issue 2 years ago • 0 comments

I can't figure out the logic for changing scenes. I have an initialisation scene that is doing some booting up and registering with a backend service before loading the main scene. All of the classes that I need actually are set up in the root lifetimescope.

In my Init scene I have a simple LifetimeScope that has the root lifetime scope as a parent. There's actually no bindings setup in it, it's just there to bootstrap the root scope and has a monobehaviour from the scene on it's list of autoinjections. I can see in the Diagnostics that I have two scopes, once called RootLifetimeScope and one called InitScope. This runs fine.

InitSceneScope

Once this initialisation is done, I load the main application scene. In this scene is the exact same set up, a scene based scope on an object and a monobehaviour listed on it to be auto injected. Identical setup. The issue is the injection methods are never called on this second scene's gameobject. The Diagnostics window shows the Root and Init scopes still.

I've tried loading the scene both synchronously and asynchronously and I've tried Enquing the root scope even though that felt like it was against the point of the root scope. In all cases, the init scene never leaves the diagnostic window (although the gameobject is gone when the scene unloads).

If I run the Application scene directly, I can see the Root and Scene scope instead. ApplicationSceneScope

but when changing scenes it never seems to start up. Any help appreciated.

adamsingle avatar May 26 '23 10:05 adamsingle