How to setup Newtonsoft.Json-for-Unity Using Burst Compiler and Jobs Package that uses NewtonSoft com.unity.nuget.newtonsoft-json@2.0.0-preview?
ArEnSc opened this issue · 4 comments
com.unity.nuget.newtonsoft-json@2.0.0-preview
Hey so Unity 2020.1.15f1 is using this package, I guess it's their internal package, and it basically causes some dll issue, when you delete one of them, it doesn't really build.
Mind you I am very new to unity not sure how this would be resolved.
I want to use both the packages, since I was using them before, I introduced the ... burst compiler and jobs package thus breaking most of my code.
These are the two I am looking to use:
https://github.com/jilleJr/Newtonsoft.Json-for-Unity
https://github.com/jilleJr/Newtonsoft.Json-for-Unity.Converters
Could you explain to me how I would get this to work with alongside with
com.unity.nuget.newtonsoft-json@2.0.0-preview
Hello @ArEnSc! Thanks for reporting this. I've yet to updated the documentation on the README.md's on the different repos.
Unity's package, the com.unity.nuget.newtonsoft-json@2.0.0-preview
one, is actually this package but I think version 12.0.201 or something. I'm trying to talk this over with Unity so we could try find a solution where either I redirect my users to their or the other way around, because this mix is not that healthy for the eco system.
Given that though, you can safely rely on Unity's Newtonsoft.Json package instead, especially since the Burst compiler/jobs packages seem to indirectly depend on it.
The converters package, https://github.com/jilleJr/Newtonsoft.Json-for-Unity.Converters, doesn't actually have a hard dependency on the package from this repo, https://github.com/jilleJr/Newtonsoft.Json-for-Unity. You can mix the "Newtonsoft.Json" DLLs however you want. Being using the converters package together with raw DLLs you've added into your Assets directory, using SaladLab's package https://github.com/SaladLab/Json.Net.Unity3D, using Unity's own package com.unity.nuget.newtonsoft-json@2.0.0-preview
, or using this repo. All should work fine.
So to resolve your dependency issues, go into the YourProject/Packages/manifest.json
file and replace the package reference of this repo with the Unity one, essentially doing this:
diff --git a/Packages/manifest.json b/Packages/manifest.json
index 49a3afa..f0edd27 100644
--- a/Packages/manifest.json
+++ b/Packages/manifest.json
@@ -18,7 +18,7 @@
"com.unity.collab-proxy": "1.2.16",
"com.unity.test-framework": "1.1.22",
"com.unity.ugui": "1.0.0",
- "jillejr.newtonsoft.json-for-unity": "13.0.102",
+ "com.unity.nuget.newtonsoft-json": "2.0.0",
"jillejr.newtonsoft.json-for-unity.converters": "1.0.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
Hope that resolves your issue!
Thanks!, I am wondering why they just don't adopt your library since it solves all the problems more or less with serialization in unity
They kind of have already. If you get the 2.0.0 version of the package and check the FileVersions of the DLLs, they've actually just taken the exact same DLLs from my 12.0.301 release, and in the Third Party Notices.md
they've correctly stated that it's based on work by both me and the other that I've referenced in my THIRD_PARTY_NOTICES.md.
They have just adopted this package. They actually asked first in an email, which is really kind of them. I'm hosting it as OSS just so other can take it and host it elsewhere.
The big question that I'm working on resolving with them is why we still have two different repos for it still. One hosted by Unity and one here at GitHub. There is a plethora of ideas swimming around, and nothing finalized, but hopefully 2021 will be a year of good Newtonsoft.Json progress for making these kinds of descisions. Would be grand if it was still hosted as OSS, perhaps over at https://github.com/Unity-Technologies, and then I can just archive this repo and refer to the officially hosted repo.
Want to restate that nothing is decided yet. We'll see how this turns out. So far, Unity has taken small steps in this because they have very limited resources on this topic. But as more and more users and customers of Unity is starting to complain, maybe they will find some time for this.
Edit (2022-02-05): It's past end of 2021 and we still don't have a resolution for this. See #145 for a more detailed explanation of why.
kk ill give your fix a shot thank you for the quick replies!