通过VS的包管理器添加了Newtonsoft.Json到项目里面。
在这里插入图片描述
虽然在VS里面可以正确引用命名空间 Newtonsoft.Json
但是Unity报错:

the type or namespace name ‘newtonsoft’ could not be found (are you missing a using directive or an assembly reference?)

看来是Unity找不到程序集,这是因为Json.NET官方没有直接支持Unity。

解决办法:GitHub上有大佬开发了正确在Unity配置Json.NET的工具

地址: Newtonsoft.Json-for-Unity

只需要下载一个Unity包然后导入到Unity中就行了
在这里插入图片描述

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐