Any way to have scenes load all required persistent objects?

I have a globals object that I create on my developer splash screen to hold things like the score, difficulty level, sound and music levels, etc. I have it persist through the game.

In my other scenes I reference the global vars stored in the persistent object without a problem.

But, if I try to edit any scene except for the splash screen and run it in Unity I get null reference errors since the global object is not present (it’s created in the splash screen that doesnt execute when playing another scene.)

Is there a way to play a scene to test in Unity but have it load the prior scenes or start at the prior scenes so I can actually test what I’m doing? Right now I have to load the scene I want to edit, make my chnages, re-load the splash screen, and then test from there. Needless to say it’s not the fastest method in the world.

Thanks!

Have a small script in each scene that checks for the existence of the manager object with your persistent variables, and if it doesn’t exist, load the splash screen and jump back to the current scene. This would require another global variable or two, so your manager object in the splash screen knows to skip to a specific level automatically.

–Eric

I didn’t think about that, works great, thanks!