r/Zenject•
kurti256

How do I use Zenject 8.0.0 to allow unity 2019.2.12 to allow cross scene referances

So I have a scene that contains just my player, and a scene per terrain (so I can load and unload different scene setups without having to unload the player). In the terrain scenes, I just find the player through code, because I know the player scene will always be loaded. so my question is how do I let the player's script referance an object in another scene?

Posted Nov 21, 2019, 11:19 AM UTC

11
whirlibulf•

You can only inject references from the current container or parent containers. If the player object is in the top level container, then it can't inject anything from the child container (the child scenes).

Workarounds:

You can rearrange which container the player is in, or rearrange the scene contexts.

You can use a signal to pass references from the child container to the parent.

You can inject the parent into the child, then set the reverse reference manually.

1