First, Unity automatically serializes the public variable, which means that the serialized variable is valued when it reads unity again, and does not require you to assign a value again because it has been saved. Then, what value will be displayed on the panel? The value that has been serialized, but not marked with Hideininspector. [Hideininspector] means that the serialized values that were originally displayed on the panel are hidden. [Serializefield] means that private variables and protection variables that would not otherwise be serialized can be serialized, so that they will be the value of your last assignment at the next read. 1 If A is a public serialization variable. 1.1 If you want to see a in the panel, then use: public int a;1.2 If you don't want to see a in the panel, then use: [Hideininspector]public int a;//so that a can be assigned to code in the program, However, you will not see it in the panel and set the assignment manually. 2 If A is a private serialization variable that you want to read and save in the panel, then use: [Serializefield]private int a;3. If a is a private serialization variable, you want to read it in the panel, but not save it, then use: [hideininspector][ serializedfield]private int A;public int b{get{return A;} Then display in editor, Editorguilayout.labelfield ("value", game. B.tostring ()); 4 If A is a private serialization variable, you do not want to do anything in the panel (you do not want to see it, you do not want to write it), but you want to assign a value to it in the program. [Hideininspector] [serializedfield]private int a;public int b{get{return A;} Set{a = value;}}
Unity3d Serialization Serializefield