Can I have a scope and its dependencies live across scenes and be injected when new scene loads? #390
akoolenbourke
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, just investigating this plugin and have a question. We have 3 scenes, and I understand if I put a derived LifetimeScope GameObject in the scene my registered items get injected correctly. Can I have that same instance for the singleton ones, injected into other scenes that are then loaded later?
I.e I have an object that represents some part of my game state. It is first used in scene 2 (Scene 1 is the menu) and I can get that injecting OK, but when it then goes to scene 3, I want that same instnce of the game state to be injected into objects in scene 3.
What is the best way to do this? Do I just dontdestroyonload the my custom LifetimeScope, or do the objects just live between scenes anyway?
Ideally, because scene 3 gets reloaded (On player death etc) multiple times, it'd be best if it could keep living until the player quits and the game goes right back to scene 1.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions