API reference
The whole public surface on one page — saving, loading, slots, backups, files, references, spawn, cloud, migrations and diagnostics.
Saving and loading#
| Member | Notes |
|---|---|
Persist.Save(key, value) | Numbers, true/false, text, char, enums, Unity value types, your [Serializable] classes and structs |
Persist.Save(key, array) / (key, List<T>) / (key, Dictionary<K,V>) | Including T[][], List<List<T>>, Dictionary<K, List<V>>, with no wrapper class |
Persist.Load(key, defaultValue) | The default comes back when the key is missing or the save cannot be read |
Persist.SaveRaw / LoadRaw | Text or bytes, stored exactly |
Persist.SaveCustom / LoadCustom | For a type that brings its own format through IPersistCustomValue |
Persist.LastResult | What the most recent call did: Ok, Code, Message, NextStep, Recovered, RecoveredFrom |
Components and fields#
| Member | Notes |
|---|---|
Persist.SaveComponent(key, component) / LoadComponent | One component's own fields, restored in place |
Persist.SaveComponentFields(key, component, fields) | Only the fields you chose — PersistKitFieldSet with a Save and a Load flag per field |
PersistKitBehaviour | The no-code component: tick fields, choose a key, save and load at the right moments |
References#
| Member | Notes |
|---|---|
Persist.Save(key, someTransform) / LoadReference<T> | A reference to an object in a scene, stored as its PersistKitIdentity id |
PersistKitAssetRegistry | The table that turns an asset into a short key and back. Instance overrides where it is found |
Persist.Spawn(prefabKey, instanceId, parent) | Makes an instance of a registered prefab, with a stable id |
Persist.SaveInstances(key, instances) / LoadInstances(key, parent, into) | The objects the game spawned, restored without duplicating anything |
Slots, backups and files#
| Member | Notes |
|---|---|
Persist.Slots.List/Inspect/Create/Select/Rename/Relabel/Delete | Named slots, each with its own file, backups and description |
Persist.Backups.Keep/Count/Restore | Rotating copies of the file each save replaced |
Persist.Files.Exists/List/Delete/Rename/Copy/Path | Anything that replaces or deletes data needs confirm: true |
Protection and location#
| Member | Notes |
|---|---|
Persist.Protection.SetPassphrase / ClearPassphrase / IsEnabled | AES-256 + HMAC-SHA256, off until asked for |
Persist.Protection.Compress / Iterations | Deflate when it helps; PBKDF2 rounds (120,000 by default) |
Persist.SaveFolder / SetSaveFolder(path) | Where saves live |
Cloud#
| Member | Notes |
|---|---|
Persist.Cloud.Provider | A FolderCloudProvider, a RestCloudProvider, your own, or null for "off" |
Persist.Cloud.Upload/Download/Sync/Status(slot) | Returns a request to poll or to yield on |
Persist.Cloud.Resolve(slot, choice) | Answers a conflict: KeepLocal, KeepRemote, KeepBoth |
Persist.Cloud.PendingUploads() / FlushPending() | The offline queue |
Persist.Cloud.Policy / DefaultChoice / LastConflict(slot) | How much is automatic, and which standing answer to use |
Migrations#
| Member | Notes |
|---|---|
Persist.Migrations.Add(new SaveMigration(from, to, why)) | .Rename, .SetDefault, .Remove, .Convert, .Custom |
Persist.Migrations.SchemaVersion | The version this build writes |
Persist.Migrations.Preview(slot) | What would change, written as a report, writing nothing |
Persist.Migrations.Apply(slot, confirm: true) | Copy first, migrate in memory, validate, write, roll back on failure |
References in bulk#
| Member | Notes |
|---|---|
Persist.SaveReferences<T>(key, items) | A list of references in one call: scene objects by identity, or assets by registry key. One list, one kind — mixing the two is refused with what to do instead |
Persist.LoadReferences<T>(key, into) | Fills the list in the saved order. An item that cannot be found leaves an empty position and is reported, so nothing shifts along |
Persist.LoadReference<T>(key, defaultValue) | One reference, resolved as the type you ask for |
Components#
| Member | Notes |
|---|---|
PersistKitAutoSave | Automatic saving: an interval, the pause/focus/quit moments, SaveNow(), Checkpoint(), LastResult |
PersistKitSaveMenu | A finished save and load menu built at runtime: Open/Close/Toggle, SaveInto/LoadFrom/DeleteSlot, and the events your game answers |
PersistKitBehaviour | Saves a chosen set of an object's fields, with no code |
Offline progression#
| Member | Notes |
|---|---|
Persist.Offline.Elapsed() | How long the game was closed, with Capped and ClockWentBackwards telling you what was measured |
Persist.Offline.MarkSeen() / Begin() / Reset() | Record the latest visit, start a session deliberately, forget the record |
Persist.Offline.MaxOfflineSeconds / ClockPolicy | The longest a session is worth, and what to do about a clock that moved backwards |
Persist.Offline.HasRecord / LastSeenUtc | Whether there is a record, and when it was made |
Diagnostics#
| Member | Notes |
|---|---|
Persist.Diagnostics.Report() / ToText() | Versions, the save folder, every slot's state and size, and the last problem |
PersistError codes | Every failure carries one; the catalogue explains each |
Conventions#
- Failures are values. Expected problems are returned, not thrown. Only a mistake in calling code — an empty key — throws, because a save that silently goes nowhere would be worse.
- Keys are text, and saving the same key again replaces the value rather than adding a second copy.
- Call from the main thread, which is where
Awake,Start, a button handler andOnApplicationQuitalready are.
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 · Error codes · Platforms and limitations