Skip to content

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.

  1. Inspect the context's existing TunalPersistence component. Assign a stable Context ID and a catalog for profile selections.
  2. Review Select State To Save. Keep Time/Calendar enabled; leave optional scene-specific sections off until their targets are configured.
  3. Choose a unique Local Folder/Slot combination. A slot named autosave does not schedule automatic saves.
  4. Create ContextSaveButtons.cs from the full example. Assign the persistence component and put the script outside switchable roots.
  5. Connect two uGUI Buttons to Save and Load. Enter Play Mode, save, inspect the result/warnings, change the clock, then load.
  6. 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.