Prefab not changing variable's values

I have a grenade prefab, which has a grenade script attached to it, originally when i made the prefab i had certian values assigned to the variables in the grenade script.

After i change the grenade scripts varaible values :


public float LaunchForce = 20;
public float BlastRadius = 2;


public float LaunchForce = 30;
public float BlastRadius = 0.5f;

The prefab doesnt get updated after compiling the script and running, is this intentional?

Once the prefab is serialized, the values on disk will overwrite the defaults in your script. If that’s a problem, you have a few options:

  • Correct the prefab’s values manually
  • Create a new component, which should have the most recently compiled values
  • Disallow Unity from serializing those values (by making them protected/private, or by using the NonSerialized attribute)

The Inspector has an elephant’s memory: it remembers forever the values you’ve initially set or modified in the Inspector, and changing them in the script has no effect (unless you modify the variable’s type). Click the “gear” object at right of the script’s name in the Inspector and select reset to update the public variables according to the script, or change them in the Inspector (not when the game is running! - these changes are lost).