How do I reference something in another scene?

Back


The multi scene asset currently only support hard coded references in your scripts. An inspector option is planned once I figure out a nice enough solution for the problem. To reference between scenes you will need to use the MultiSceneRef.cs class & its methods.

From here you can use a GetComponent style of referencing with the option to pass through particular scenes, the active scene or all loaded scenes. You can also use a FindObject style as well but not that it will be a lot less performant, so use it sparingly as it goes through each object in every scene including children to find objects.

One thing to note when using the MultiSceneRef.cs class is that you will need to make sure the scene the reference is in in actually loaded when the reference is made. It is recommended you use the Multi Scene Listener Interfaces or the post scenes loaded event from the multi scene manager. While you can use the standard unity awake/enable/start methods for these references you will need to make sure the scene is loaded after the scene with the reference in it to get the reference correctly. You can also get references within the same scene using the same class for cross scene references should you wish.