system
1
Hello,
I have been testing scripts that I am working on, in the most recent version of Unity on a 64 bit Windows 7 machine. When I assign a variable the first time, then run the code everything is hunky dory. If I change the amount of the variable and run the code again, very often the variable will not be updated. To get the code to run with the updated variable, I have to rename all the variables with the find and replace tool. I’ve tried restarting the application, and even rebooting the machine when this issue arise. I was wondering if anyone else was having this same problem and if a solution has been discovered.
Best Regards,
Steve
Waz
2
Serialised variables (those that appear in the inspector) will keep their values from the inspector even if you change the code. Your options are:
- Add System.NonSerialized attribute to them, or
- Mark the variables private if no other class needs to access them, or
- Right click in inspector and revert the value.
In general, choose carefully what you want to set from code and what from the inspector.