Question by
jupiter · Aug 25, 2020 at 04:34 PM ·
scripting problemserializationcompiler
Compiler ignores data changes on [Serializable] classes
I have the following class:
[Serializable]
public class SaveLoadTestClass
{
public string string1 = "example 1";
private string string2 = "example 2";
}
I run it in Unity and attach the VS to Unity. When an instance of the class is created, debugger shows string1 as "example 1" and string2 as "example 2", all fine.
I then stop both the Unity project and the attach and change string1 to anything else. The value still stays "example 1" after running. Only when I change the variable name to string123 or something or change the access level does the compiler get the change.
This problem goes away if I don't use [Serializable].
Any explanations and fixes?
I assume it is some sort of an optimization with the compiler but it may be something else.
Comment
Your answer
