Generated code
The code the Inspector offers for your configuration, what it uses, and the framework internals it deliberately never mentions.
Where it comes from#
The Inspector's Code section generates a snippet from your configuration — the real slot, the real schema version — using public APIs only. Because it is generated from the settings asset rather than typed by hand, pasted code and configuration cannot quietly disagree. The Samples & code page of the settings window does the same, and lists the four importable samples and the documentation in reading order.
Two depths, matching the Inspector modes#
- Beginner shows the simple API: ``
csharp await NexusForgePersistence.Save("player", playerData); var loaded = await NexusForgePersistence.Load<PlayerData>("player");`` - Advanced shows the capture → save → recover flow the component performs, with the explicit service calls.
What generated code never mentions#
The envelope, compression, encryption, integrity, storage and migration types. Those are the framework's business, not the game's: a snippet that made a game responsible for a container's internals would be teaching the wrong thing. It also never emits anything the validation panel flagged as unsupported.
Where the runnable versions live#
Four samples, importable from Package Manager → NexusForge Persistence → Samples:
| Sample | Shows |
|---|---|
01_BasicSaveLoad | Save, load, autosave, flush on pause |
02_CloudSync | Provider, offline queue, preserved conflict |
03_MigrationAndVersioning | Schema 1 → 2, unknown members preserved |
04_PersistentObjectsAndCheckpoints | Stable ids, rotating checkpoints |
Each has its own assembly definition, so it compiles cleanly in a project of any size and can be deleted without leaving dangling references.
Next#
- Samples — what each sample demonstrates and what it costs to read.
- API overview — the surface the generated code is drawn from.
- No-code save component — the component the snippet replaces.
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