About Serialization
ALE will attempt to serialize all your exposed components and custom fields. The serialization backend is provided by MessagePack for C# to enable fast and performant serialization both to Binary and JSON (see JSON note).
Exposed Components​
ALE will serialize all components that have been exposed to the level editor. (See Expose To Level Editor attribute) It can serialize all the standard C# primitives, Unity primitives, and some custom types.
Generated Code
Custom Data​
Custom data is, as the name implies, custom data being saved with the level data when saving. You can save the standard C# primitives, Unity primitives, and some custom types in custom data and retrieve it later when loading a level. See save manager for more info about actually using custom data.
Serialization Rules​
There are some rules that the weaver follows to create formatters for your exposed components and custom types. They can be really helpful in order to get the most reliable output from your data.
When serializing exposed components:​
- Unity object/component references ARE allowed
- Only specified fields and properties are serialized
- Exposed properties are mapped to their ID
- Private, protected, and public fields/properties can be serialized
When serializing custom types:​
- Unity object/component references ARE NOT allowed
- Only structs can be serialized
- Only fields are serialized
- All fields are serialized
- Fields can be ignored with the
NonSerializable
attribute - Fields are mapped to their names
- Only public fields are serialized
Custom Formatters​
âš Custom formatters are not yet supported. âš
Custom formatters give you the ability to easily create your own formatter that will be hooked into the level editor so you can customize the serialization behavior of your custom types.