Anything like JsonUtility

Issue #222 resolved
William Besnard created an issue

Hi!

Is there any sort of functionality in Odin like the JsonUtility.FromJsonOverwrite (and ToJson) from Unity that would work with SerializedMonobehavior or SerializedScriptableObject?

Thanks!

Comments (2)

  1. Tor Esa Vestergaard

    Unfortunately, you cannot save a Unity object to its own separate "set" of serialized data such as a file or merely a json string, as there are fundamental issues with the way Unity handles asset references that makes this impossible to do reliably in any way. In our special SerializedObjects, we merely keep a list of Unity object references that Unity then serializes itself, and in our own data we only serialize the indices of the objects in that list, to be fetched out again on deserialization. However, this only works in the context of a Unity object, as only there can we offload the serialization of Unity object references to Unity itself. If we do not have such a Unity context, you cannot serialize references to Unity objects at all.

    However, if you merely want to serialize non-Unity-related "plain C#" data to and from json using Odin, that's perfectly possible to do.

  2. Log in to comment