A drop-in solution providing custom converters for Unity types, no configuration required.
Newtonsoft Json, which has been officially supported as a Unity package as com.unity.nuget.newtonsoft-json
, has trouble serializing most native Unity types such as Color
, Vector2
, Vector3
and many more. This is due to self-references in the struct types Unity uses, which runs Json.NET into an infinite serialization loop.
This package adds custom converters for these Unity types into your project and automatically adds them to the default configuration of Newtonsoft Json in both editor and runtime. No configuration required - plug and play.
- In your package manager (
Window > Package Manager
) choose the+
. - Select "Add from git URL"
- Enter
https://github.com/AbandonedCrypt/unity-json-converters.git
and go. - You are done and ready to de-/serialize
Currently only the following are supported, but with time, all will be added.
- Color
- Vector2
- Vector3
- Vector4
You can do so by modifying the default settings in your project and adding the converter using the OverwriteAll
extension method on the JsonSerializerSettings.Converters
collection. It does not matter if that modification gets executed before or after this package.
Its stupidly simple. Even a beginner could maintain a fork of this, were I to stop doing so.