Unity 中解决序列化私有变量导致的警告

warning CS0649: Field 'XXX' is never assigned to, and will always have its default value null
warning CS0649: Field 'XXX' is never assigned to, and will always have its default value null
warning CS0649: Field 'XXX' is never assigned to, and will always have its default value null

由于脚本中存在序列化私有变量的情况,就像下面这种情况,这种情况会被unity识别为变量未初始化

[SerializeField] bool isOK;

本着开发者的原则,尽量不要让程序中出现警告,我决定解决这个问题。
只需要屏蔽这条警告即可。
解决方法如下:
在Asset目录中新建文件命名为csc.rsp,在里面添加如下内容:

-nowarn:0649

保存,然后重新打开unity编辑器,警告就不会再显示了!

上一篇:window下运行nginx出现nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a s


下一篇:Websocket————错误总结