Choose a serializer

A serializer turns your asset's data into the bytes a save holds, so it decides which members of your class reach that save. Persistent Asset works with four of them, and each manager carries its own. To change it, select one from the Serializer dropdown in the manager's Inspector window.

The Serializer dropdown open on a manager

If your project already uses Newtonsoft or Odin, you can keep to that one here: it appears in the dropdown as soon as its library is in the project. Otherwise, the choice follows what your class holds:

SerializerChoose it whenNeeds
Unity JSONUnity's own serialization reaches everything you save. This is the default.Nothing
Newtonsoft JSONYour class holds dictionaries, properties, or a field whose type Unity's serialization doesn't reach.The com.unity.nuget.newtonsoft-json package
OdinYour class holds what Unity's serialization can't, and the save should be binary rather than JSON.Odin Inspector, or the free standalone Odin Serializer
MemoryPackThe size and the speed of a save matter more than anything else.The com.cysharp.memorypack package and the MemoryPack NuGet libraries
Note: Three features read an old save field by field, and need a serializer that can produce those fields: save upgrades, merging and field resets. Unity JSON, Newtonsoft with Shared references off, and Odin set to Json can. MemoryPack and Odin Binary can't.
Note: Only Unity JSON runs Unity's own ISerializationCallbackReceiver on your nested types. Implement ISerializationCallbacks on the asset instead, which every serializer calls.

Unity JSON

Unity JSON writes the save through Unity's own serialization, so a save holds the fields Unity itself serializes. It is the default, and needs nothing added to the project.

For the rules those fields follow, refer to Unity's script serialization documentation.

Newtonsoft JSON

Newtonsoft JSON reaches what Unity's serialization leaves out: dictionaries, properties, nullables, a field that is null rather than an empty instance, and a field whose type Unity refuses. Switching to it never drops a field.

For what Newtonsoft supports and how to configure it, refer to the Json.NET documentation.

Note: A save Newtonsoft writes names the type of each class it holds, so renaming or moving one of your classes stops existing saves loading.

Odin

Odin covers the same ground as Newtonsoft, and saves shared references and polymorphic types with nothing to configure. Its Binary format produces a way smaller payload than its Json one, and writes it far faster.

For what Odin supports, refer to the Odin documentation.

Note: Generate Odin's AOT support before an IL2CPP build, or the load fails in the player.
Warning: Odin constructs whatever type a save names, which a save that arrived from elsewhere can turn into a way into the player's machine: what the save names is what your game builds. The package refuses types that do real work when constructed, by family rather than one by one, so treat that as a minimum. Protect saves that can arrive from off the device with encryption or a save anchor.

MemoryPack

MemoryPack writes the smallest and the fastest saves of the four, but it has limitations and takes some setup. Your persistent classes have to derive from MemoryPackScriptableObject and follow MemoryPack's own rules about the members it writes.

For those rules, refer to the MemoryPack documentation.

Warning: MemoryPack saves a narrower set of members than the other serializers, and reports nothing about the ones it leaves out.
Warning: MemoryPack writes only classes you can mark yourself, so it can't write the package's own assets: Persistent Variables, Prefs, a slot registry or a Scene State.

Size and speed

The following table compares the four serializers on one save that holds 700 objects, each with a name, a transform, a few values and a short list.

SerializerSizeGzippedRound trip
Unity JSON428 KB78 KB8 ms
Newtonsoft JSON377 KB65 KB35 ms
Odin Json554 KB61 KB137 ms
Odin Binary182 KB45 KB6 ms
MemoryPack55 KB32 KB0.7 ms

Until a save grows large, compression changes its size more than the choice of serializer does.

Change the serializer later

Changing a serializer is possible even after your game has shipped.

Each serializer writes a different format, so one serializer can't read what another wrote. When you change the serializer on a locked manager, the package offers to keep the old setup as an import copy, which reads those saves once and writes them back in the new format.

Create your own serializer

To save data in a format the built-in serializers don't support, create a class that inherits Serializer. Your class then appears in the Serializer dropdown alongside them. For more information, refer to Create a custom serializer.