The Windows package of IL2CPP released by Unity does not support Newtonsoft.Json.dll

Record:

The project was officially released for testing, so after packaging the IL2CPP post-processing Windows package, I found that there was no response when running. After checking the log, I found that Json reported an error.

Since IL2CPP will cut the code when packaging, I thought that the JSON library was cut out at first, so I wrote the link. If it still doesn’t work, check the log again, and the Json error is still reported.
Insert image description here
At this point, I started to query the cause of the error, and finally found that IL2CPP does not support runtime code generation, resulting in the commonly used Newtonsoft.Json library not supporting it. According to the search provided in the picture, I finally found the
Insert image description here
Newtonsoft.Json library that supports IL2CPP. Adding the library needs to be in the project Just add the reference library to the Packages/manifest.json file of the project. After opening the project, the corresponding json library will be automatically imported and can be viewed in the Package Manager. If there is a new version, it can be updated directly in the PackageManager. The content that needs to be added to manifest.json is as follows
Insert image description here

{
    
    
  "scopedRegistries": [
    {
    
    
      "name": "Packages from jillejr",
      "url": "https://npm.cloudsmith.io/jillejr/newtonsoft-json-for-unity/",
      "scopes": [
        "jillejr"
      ]
    }
  ],
  "dependencies": {
    
    
    "jillejr.newtonsoft.json-for-unity": "13.0.102",
  }
} 

Guess you like

Origin blog.csdn.net/weixin_43872129/article/details/131842137