DontDestroyOnLoad doesnt work ouside editor
In my game, I have a game manager. I need this to persist between loading stages. When I hit the play button from the editor, it works fine. I navigate from the start menu to the character select menu and I can select my character.
When I build, I can't use the character select button because of a null reference error exception. This same code works fine when I just hit the play button from the editor.
if (gm.gameMode.Equals("Single"))
gm - is the name of the object that was supposed to persist on each level.
Answer by Hsni · Sep 18, 2018 at 12:03 PM
https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html
may be this will help
Answer by Zerai · Sep 18, 2018 at 04:09 PM
I understand how it works. My issue is that it only works in the editor. When create a build, it is not working and I get null reference errors when trying to access it.
Your answer

Follow this Question
Related Questions
unable to use dontdestroy on load 1 Answer
Problem with Awake 2 Answers
How to have a script run between 2 scenes 2 Answers
I am wondering how to save a int in the background 2 Answers
Dropdown menu: how to make colour change across multiple scenes 0 Answers