NonSerialized 非序列化
Inherits from Attribute
The NonSerialized attribute marks a variable to not be serialized.
NonSerialized非序列化属性标记一个变量不能被序列化。
This way you can keep a variable public and Unity will not attempt to serialize it or show it in the inspector
这个方法你可以保持一个变量公有并且Unity不会尝试序列化它或者显示在inspector(检视面板)。
// p will not be shown in the inspector or serialized
// p将不被显示在inspector(检视面板)和序列化。
@System.NonSerialized
var p = 5;
// C# Example
class Test {
// p will not be shown in the inspector or serialized
// p将不被显示在inspector(检视面板)和序列化。
[System.NonSerialized]
public int p = 5;
}