Does Unity cache global variables between test plays? I notice that when I create a global variable (Outside of any function/method) and initialize it in the same line as the declaration, run the game, then change it and run the game again, the new value doesn’t take effect. (I do stop the test play before I edit it and save, so it’s not like I do this while the game is running) Is this intended behavior? If so, how do I make it recognize the change?
I know using global variables is bad coding practice, I’m going through a tutorial that has code that uses them. Just want to understand why the engine is acting the way it is.
To duplicate:
Waz
2
There are no global variables. What you are seeing is variables visible in the Inspector being saved. If you don’t want this for a variable, mark it private or NonSerialized. See this question.