I have public variables and Color values that were previously set using the Inspector menu. But now I’m setting the same variables through script, the old Inspector values are still overwriting my script defined values! How can I remove the Inspector values? I tried Reset option on the menu but it’s still the same.
I’ve spent hours debugging my script only to realize the Inspector is the culprit! Any solutions besides renaming my variables?
Create a getter function. Possibly setters if you need them.
C#
private Color myColorValNotInInspector;
public Color ColorVal {
get {
return myColorValNotInInspector;
}
}
// In another script...
Color color = theScript.ColorVal;
UnityScript
private var myColorValNotInInspector : Color;
public function GetColorVal () : Color {
return myColorValNotInInspector;
}
// In another script...
var color : Color = theScript.GetColorVal ();
This is another solution, which will likely serve your purpose. However if your variable is something that shouldn’t be set at any time, and you have only made it public in order to access it in other scripts, what I have proposed would fit nicely.