Stand-Alone Build Does Not Retain Player Values But Editor Version Does

I have a GameManager object that is set to DontDestroyOnLoad and it stores player values from a menu (the menu is in its own scene). When the player advances to the next step (still in the same scene), the values are printed in a Text box and all show the correct values (e.g. UserName), in both the game running in the editor and the stand-alone build. When the player advances to the game scene, however, the values are lost in the stand-alone version of the game (empty string when I print the text to the game screen). The thing is, this doesn’t happen in the editor version of the game. All values are successfully carried across to the game scene. I tried with just two stand-alone builds but, again, the values are null.

Has anyone seen this type of behaviour before?

No. Maybe do a search for #if UNITY_EDITOR and #if DEBUG or any other preprocess statements, which might change between editor and build. Other than that there is the EditorOnly tag for GameObjects, which get removed, but that’s probably easy to notice.

Have you tried to debug the issue with log statements or a debugger? Does the line with DontDestroyOnLoad get called? What happens in the new scene, where the values are lost? Is the GameManger being destroyed or instantiated a second time?

1 Like

Thanks @Xarbrough_1 , you helped me track it down. I looked at all of the options that you presented, and GameManager was instantiated a second time. I really appreciate the help.