Save and restore one context¶
First test saving time and date before adding presentation and lifecycle state. This makes configuration and identity problems easier to isolate.
- Inspect the context's existing
TunalPersistencecomponent. Assign a stable Context ID and a catalog for profile selections. - Review Select State To Save. Keep Time/Calendar enabled; leave optional scene-specific sections off until their targets are configured.
- Choose a unique Local Folder/Slot combination. A slot named
autosavedoes not schedule automatic saves. - Create
ContextSaveButtons.csfrom the full example. Assign the persistence component and put the script outside switchable roots. - Connect two uGUI Buttons to Save and Load. Enter Play Mode, save, inspect the result/warnings, change the clock, then load.
- Confirm the selected state returns and repeated Save/Load calls are ignored while a confirmed save is pending. Add visual Button interactivity feedback in your own UI if needed.
For an in-memory checkpoint instead of a file, use ContextSnapshotMemory from the same guide. For WebGL, wait for confirmed storage synchronization and test the deployed player; a synchronous write is not evidence of durable browser storage.
Do not regard a successful result with warnings as proof that every optional section was captured. Restore preflight does not guarantee rollback after a later failure. Keep application-specific gameplay data in your own save format.
Related: catalogs and IDs, storage and failures.