Variable not updating/saving !
So in visual studio line goes
public float enemySpeed = 0.2f;
but in Unity when I change it to lets say enemySpeed = 1 it stays like that even when I stop "Game" and restart Unity even tho its enemySpeed = 0.2f in script.
Answer by Hatsuko · Oct 26, 2017 at 02:32 PM
Hello. This is how Unity designs it to be. If your variable is public, then it's value can be changed in the Inspector. That changed value is serialized (sort of saved). Even if you changed the default value you declared in script, in your scene that value will stay the same. The idea is that you expose those variables you want to modify (sort of fine-tune) in the Inspector as public. In this scenario you wouldn't want your value resumed when you change default value in script.
So you just manually change that value in the scene to 0.2. Or if you want to resume all value to default, click on the little gear at the top right corner and click Reset. If you just don't want to expose it at all, make it private.
PS. it happens when you save the sceneThat changed value is serialized (sort of saved)