I have tested some small projects and during testing some scripts, I have found a Bug.
-When I write a Javascript and set a variable (and save the script before):
var Test=9;
-add the script to a GameObject, so that you see the value of GameObject in Inspector. (=9)
-now start the scene
-stop the scene
change the var now in script to:
var Test=10;
and save the script file. Now the Value in Inspector Test= is still 9!! Also after starting the scene.
I must change the value in Inspector separately for the attached Game Object.
It’s a feature. It would be extremely annoying if it didn’t work that way…would you really want your scripts overwriting your inspector values every time you re-saved them?
When I now want change a variable in script, I must then change all the Values in attached GameObjects ?
It’s big work if your make a big project and very dangerous.
It’s hardly bad; it’s the way Unity is supposed to work. One of the major features is rapid development, where you can quickly tweak values in the inspector to get results without having to recompile scripts all the time. It is not possible to disable this behavior.
Just use a loop with FindObjectsOfType(// name of your script)
if you ever need to change everything at once like you’re talking about. I don’t find it useful that often, but you can do it like this when you need it.
You can also just use a private variable if you want the script to have 100% control over a variable’s default value, or assign its starting value in Awake().
thanks guys for the suggestions. I’ll try it.
I’m coming from C++ Ogree and that is new for me with inspector. :lol:
I must get used to the mode of operation first