Storing scene-specific variables?

Hi,

I’m trying to figure out the best way to store scene-specific variables. For instance, each scene has a specific music song. At the moment I have a gameManager object that controls the scene (and stores these variables, like what song should play in this scene).

The problem is that the gameManager is an istance of a prefab. I want to keep it a prefab, because i want the gameManager to change across all scenes if I add new functionality to it in the future. When I “apply” changes to this instance of gameManager, the music track variable will be set to this specific one too, across all scenes.

So what is the best way to store scene-specific variables?

Thank you very much in advance!

From what I understand you have a singleton object that, among other things, functions as a music player (for lack of a better term). You can store all of the songs that are used in your project in an array on the gameManager, and have the gameManager check to see which of the scenes you are currently in, and play the appropriate song.

You should use the SceneManager to figure out which scene you are on, and use the sceneLoaded listener to add a function to select the correct song.