API reference

The whole public surface on one page — saving, loading, slots, backups, files, references, spawn, cloud, migrations and diagnostics.

Reference NexusForge Persistence 1.0.0 Updated

Saving and loading#

MemberNotes
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 / LoadRawText or bytes, stored exactly
Persist.SaveCustom / LoadCustomFor a type that brings its own format through IPersistCustomValue
Persist.LastResultWhat the most recent call did: Ok, Code, Message, NextStep, Recovered, RecoveredFrom

Components and fields#

MemberNotes
Persist.SaveComponent(key, component) / LoadComponentOne 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
PersistKitBehaviourThe no-code component: tick fields, choose a key, save and load at the right moments

References#

MemberNotes
Persist.Save(key, someTransform) / LoadReference<T>A reference to an object in a scene, stored as its PersistKitIdentity id
PersistKitAssetRegistryThe 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#

MemberNotes
Persist.Slots.List/Inspect/Create/Select/Rename/Relabel/DeleteNamed slots, each with its own file, backups and description
Persist.Backups.Keep/Count/RestoreRotating copies of the file each save replaced
Persist.Files.Exists/List/Delete/Rename/Copy/PathAnything that replaces or deletes data needs confirm: true

Protection and location#

MemberNotes
Persist.Protection.SetPassphrase / ClearPassphrase / IsEnabledAES-256 + HMAC-SHA256, off until asked for
Persist.Protection.Compress / IterationsDeflate when it helps; PBKDF2 rounds (120,000 by default)
Persist.SaveFolder / SetSaveFolder(path)Where saves live

Cloud#

MemberNotes
Persist.Cloud.ProviderA 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#

MemberNotes
Persist.Migrations.Add(new SaveMigration(from, to, why)).Rename, .SetDefault, .Remove, .Convert, .Custom
Persist.Migrations.SchemaVersionThe 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#

MemberNotes
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#

MemberNotes
PersistKitAutoSaveAutomatic saving: an interval, the pause/focus/quit moments, SaveNow(), Checkpoint(), LastResult
PersistKitSaveMenuA finished save and load menu built at runtime: Open/Close/Toggle, SaveInto/LoadFrom/DeleteSlot, and the events your game answers
PersistKitBehaviourSaves a chosen set of an object's fields, with no code

Offline progression#

MemberNotes
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 / ClockPolicyThe longest a session is worth, and what to do about a clock that moved backwards
Persist.Offline.HasRecord / LastSeenUtcWhether there is a record, and when it was made

Diagnostics#

MemberNotes
Persist.Diagnostics.Report() / ToText()Versions, the save folder, every slot's state and size, and the last problem
PersistError codesEvery 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 and OnApplicationQuit already 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