I'm having trouble with my inspector and I'm not sure what I did. Before this problem, when I would update a variable in my script, it would show the new value in the inspector when I saved the code. For some reason all of a sudden, this stopped happening. I'm not aware of any changes I made to the inspector or code that would have caused this. Is there some sort of setting to adjust this functionality? I've been pretty much working with a default unity installation and doing C# in Visual Studio. I've seen other similar problems on the web but no answers that quite fit the issue I'm having.
Here is an example variable with two different values. Basically, I initialized it in C# code with a value of 2f. Then, later on I updated the same C# code with the value 3f and saved. Normally, the inspector would update to reflect this new value but it no longer does.
Variable in Code
Variable in Inspector
That is because the fields in the Inspector are serialized and get always overwritten with the serialized values stored in your Scene or Prefab asset.
A later change in code of the default value has therefore no effect.
So I doubt it has done it before.
The only thing that does change it would e.g. be if you rename the field.
As already mentioned by Yash Vakil you can Reset the entire component and all its field via the component's context menu.
But afaik you can also reset individual fields by directly right click the field and click Reset from this context menu. Not 100% sure on that one though.
The little bit dirty hack around would be to make one compilation where this value is not serialized anymore.
E.g. by making it
[NonSerialized] public float jorneyTime = 3f;
let it compile once and then change it back by removing the [NonSerialized] again. This forces Unity to lose the serialization of that field entirely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With