Vault Save System

API Index

Vault

SignatureDescription
SetDrawer(name)Sets the active drawer.
SetDefaultDrawer()Sets the active drawer to "default".
string ActiveDrawerName of the current drawer.
BeginBatch()Suspends per-call disk writes.
EndBatch()Flushes all pending writes in one operation.
Save<T>(key, value)Saves any supported value.
Load<T>(key, default)Loads a value; returns default if missing.
Save(key, so)Saves all [Save] members on a ScriptableObject.
Load(key, so)Restores all [Save] members on a ScriptableObject.
Save(key, mb, build)Saves with a component filter builder.
Load(key, mb, build)Loads with a component filter builder.
SaveAsync<T>(key, value)Background save. Returns Task.
LoadAsync<T>(key, default)Background load. Returns Task<T>.
SaveAsync(key, so)Save(so) on background thread.
Exists(key)Returns true if the key exists.
Delete(key)Removes a key and writes.
DrawerExists()Returns true if the active drawer file is on disk.
DeleteDrawer()Deletes the active drawer and its backup.
GetAllDrawerNames()Sorted names of all drawers on disk.
CopyDrawer(src, dst)Copies a drawer to a new name.
DeleteAllDrawers()Deletes every drawer.
GetDrawerInfo()Returns the raw SaveFile for inspection.
GetDataVersion()Returns the drawer's migration version.
SetDataVersion(v)Stamps the migration version (skips old migrations).
UpdatePlaytime(seconds)Increments the drawer's built-in playtime counter.
Sheet(name)Returns a VaultSheet for the active drawer.

VaultSheet

SignatureDescription
Set<T>(row, col, value)Sets a cell. Writes immediately.
Get<T>(row, col, default)Gets a cell or returns default.
HasCell(row, col)True if the cell has a value.
SetRow<T>(row, value)Writes a struct's fields as consecutive columns.
GetRow<T>(row)Reads a typed struct from consecutive columns.
GetAllRows<T>()All rows as List<T> in index order.
ClearCell(row, col)Removes one cell.
ClearRow(row)Removes all cells in a row.
ClearAll()Removes everything in the sheet.
int RowCountNumber of rows with at least one cell.
RowIndices()Enumerates populated row indices.
ColumnIndices(row)Enumerates populated column indices in a row.
BeginBatch() / EndBatch()Batch writes for sheets.
ExportCsv(path)Exports to a sparse CSV file.
ImportCsv(path)Imports from a sparse CSV (auto-detects types).

VaultMigrations

SignatureDescription
Register(from, to, callback)Registers a migration for all drawers.
Register(from, to, callback, predicate)Registers with a drawer filter predicate.
int LatestVersionHighest to version across all steps.
Clear()Removes all steps (useful in tests).

Attributes

AttributeDescription
[Save]Include this field in Save / Load object scanning.
[Save("key")]Include with a custom key name.
[NoSave]Exclude from scanning. Wins over [Save].
[VaultRename("old")]Load from old key names after a field rename.

SaveFile

MemberDescription
string drawerDrawer name.
int dataVersionMigration version.
float playtimeTotal seconds played.
GetFormattedPlaytime()Returns "HH:MM:SS".
GetDateTime()Local DateTime of last write.
entriesList<SaveEntry> — all key-value pairs.

Supported Types

CategoryTypes
Primitivesint, float, bool, string
Extended numericsdouble, long, ulong, uint
Otherchar, DateTime, TimeSpan, Guid
Unity mathVector2/3/4, Vector2/3Int, Quaternion, Matrix4x4
Unity graphicsColor, Color32, Gradient, AnimationCurve
Unity geometryRect, RectInt, Bounds, BoundsInt, LayerMask
CollectionsT[], List<T>, Dictionary<K,V>
Custom typesAny [Serializable] struct or class
EnumsAny enum
Unity ComponentsRigidbody, Camera, Light, Transform, … all Components (via reflection)

double, long, DateTime, and Dictionary use Vault's tagged format internally since JsonUtility doesn't support them. This is handled automatically — no action needed.