Supported types

The complete list of field types that survive a save and load round trip, including Unity value types, collections and nested objects.

Unity NexusForge Persistence 0.2.0 Updated

Captured directly, with values that survive a round trip#

KindTypes
Scalarsbool, byte, sbyte, short, ushort, int, uint, long, ulong, float, double, decimal, char, string
Time and identityDateTime, DateTimeOffset, TimeSpan, Guid
Unity valuesVector2/3/4, Vector2Int, Vector3Int, Quaternion, Color, Color32, Rect, RectInt, Bounds, BoundsInt, LayerMask
CurvesAnimationCurve, Gradient — captured and restored
EnumsStored by name, so reordering members does not change what a save means
Nullablesint?, MyEnum?, Vector3? and so on
CollectionsT[], List<T>, HashSet<T>, Queue<T>, Stack<T>, Dictionary<TKey,TValue> where the key is a string, integer, char, enum or Guid
Nested objectsPlain classes and structs whose own fields are supported, up to the capture depth limit
ReferencesGameObject, Component, assets derived from PersistableScriptableObject — stored as the target's persistent id
GameObjectsIdentity, transform (local position, rotation, scale) and each supported component on it

Why enums are stored by name#

A numeric enum value means "the fourth thing in this list". Insert a member in the middle and every old save now means something else — silently. Storing the name costs a few bytes and makes a save mean what it said.

Numbers and dates are written culture-independently#

Timestamps and decimals are written in a round-trip, invariant form. This was not a theoretical concern: an early AOT run in a built player wrote timestamps using the current culture, so a save written on a device using dd-MM-yyyy could be reinterpreted elsewhere. It is fixed and covered by tests that impose deliberately hostile cultures and inspect the bytes. Verified

Next#

Something wrong on this page? Every page here describes behaviour that is checked in the repository. If a page and the package disagree, the package wins.

Report a documentation problem · Frequently asked questions · Troubleshooting