简体   繁体   中英

Issue using JsonConvert.SerializeObject with Unity IL2CPP scripting backend

I'm having issues using the JsonConver.SerializeObject function to serialize a string when using Unity IL2CPP scripting backend. My understanding is that since JsonConvert uses reflection IL2CPP cannot use this function because it is pre-compiled. I'm also using the Holotoolkit which uses the Newtonsoft.dll so I don't believe using the JSON .NET for Unity package is feasible as it will conflict with the Newtonsoft.dll

Anyone run into this or have any suggestions on how to resolve?

I got this to work by deleting the Newtonsoft.dll in the Holotoolkit directory structure as well as the GLTFSerialization.dll that references the Newtonsoft.dll. Then, since I'm coding for the Hololens I was able to comment out all code that referenced the GLTFSerialization.dll. Then I installed JSON for .NET Unity asset from the Unity asset store and all in life is good again.

I believe all of the code that references the GLTFSerialization.dll is used only for Mixed Reality device development so if you are developing for MR this solution may not work and you may want to look into using the extern aliasing method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM