Loading new scene seems to discard data

I’m going to avoid pasting code but if you guys end up needing it I’ll do my best.

I have a Startup scene that has a manager object with a GameManager class. GameManager has a DataManager instance created in the member declaration and calls DontDestroyOnLoad(gameObject) in Awake().

When the user clicks Play at the beginning of the game it begins loading the game and registers an OnDataLoaded event that will load the level selection UI in a separate scene. (I’m using Google Play Services btw). The DataManager successfully loads and assigns the data to it’s own public List LevelList. Once the data has been loaded it calls OnDataLoaded which loads the Level selection UI (this is a screen that just displays all levels in the game allowing the player to choose what he/she wants to play along with the scores of any previously played levels).

The method registered with the OnDataLoaded event loads the level selection scene and it’s at this point that LevelList becomes blank. I verified many times over with many a debug statement that the data IS being correctly loaded prior to this though. As soon as the scene switches it’s all reverted. This is a small game and there’s no other code accessing this List and I actually have zero scripts in the level selection scene. Only on GameManager with persists through scenes. Now when I say “reverts” I don’t mean the member becomes null. The data goes back to the blank template I load at the beginning of the game, which I haven’t mentioned before. It’s just all the level data in an XML file, separate from the saved game data. I load the XML level data template, THEN load the saved game, then switch scenes and the data that I assigned to LevelList goes from the saved game data back to the serialized data from the XML file. For instance, if I have a few levels with recorded scores I can see those scores via debug statements in a later session, but as soon as the scene changes everything is back to 0 (ie the XML template).

So after hours of debugging and poking it appears that changing scenes is doing something to my data, but I really can’t figure out what. I kind of feel this is a bug but at the same time I need to verify that first. Sorry for the amount of text here, I’m doing my best to articulate the problem without posting a ton of code.

If anyone needs more information or needs to see some or all of the code let me know.

Can you post GameManager and DataManager?

You might also double-check that the Level selection UI scene doesn’t have another instance of GameManager. (You can enter “t:GameManager” in the Hierarchy search bar to search for this type.)