Clearing Cached Variable

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

Serialised variables (those that appear in the inspector) will keep their values from the inspector even if you change the code. Your options are:

  1. Add System.NonSerialized attribute to them, or
  2. Mark the variables private if no other class needs to access them, or
  3. Right click in inspector and revert the value.

In general, choose carefully what you want to set from code and what from the inspector.