Skip to content

Saving and loading

Intrigues keeps a running game in save slots. This page shows the component that owns them, the calls you make from code, and what a slot holds. The other pages in this section go deeper: the results of each call, your own data in a save, and the limits of saving in 2.0.

The Save System component sits on the Intrigue Manager prefab. It keeps one file per slot in the folder Intrigues Saves, inside Unity’s persistent data folder, with the extension .isav. You can change the folder and the extension on the component.

A new file replaces the old one only when it is whole, and the old one is kept next to it as a backup (.bak), so a crash or a full disk leaves either the old save or the new one, never half of each.

The save format is version 10. This version reads saves down to version 9 and refuses older ones. Saves from Intrigues 1.x do not load.

Get the component with IntrigueSaveSystem.Instance. Every call below runs on the main thread, and none of them throws; each one returns a result object that says what happened, so you test Ok and read Reason when it is false.

Call What it does Returns
SaveAsync(slotId, request) Saves the running game to a slot. Task<SaveResult>
SaveCurrentAsync(request) Saves to the slot the game came from, or to a new slot when the game has none. Task<SaveResult>
AutosaveAsync(request) Saves to the next slot of the autosave ring. Task<SaveResult>
LoadAsync(slotId, request) Loads a slot. LoadOperation
DeleteAsync(slotId) Removes a slot and its backup. Task<DeleteResult>
ListAsync() Lists the slots, newest first, from their headers. Task<SlotList>
NewGame() Clears the loaded save. No slot is current any more. nothing

sources: Runtime/Save/IntrigueSaveSystem.cs. CurrentSlot names the slot the game was last saved to or loaded from, or is null for a new game.

LoadAsync returns a LoadOperation. You can await it, or listen to its Completed event, or read IsDone and Result. Its result is a LoadResult.

Example, an excerpt copied from the Save System sample in the package (SaveSamples.cs). The sample file’s own header says it is compiled and run by the product’s tests; this was not checked from the repository.

var system = IntrigueSaveSystem.Instance;
var list = await system.ListAsync();
var saved = await system.SaveAsync("slot1", new SaveRequest { Title = "Chapter 2" });
if (!saved.Ok) return "save: " + saved.Reason;
var loaded = await system.LoadAsync("slot1", new LoadRequest { Scene = SceneMode.FromSave });
if (!loaded.Ok) return "load: " + loaded.Reason;

A LoadRequest has a Scene field with three values.

SceneMode What happens
Current The game is restored in place, in the scene that holds the actors now.
FromSave The scene named in the save’s header loads, and the load completes when its actors have woken.
Caller As FromSave, but your code loads the game scene itself.

If you call LoadAsync without a request, the component’s Load Scene setting decides, and it is FromSave by default, but a LoadRequest you create yourself has Scene set to Current until you change it. Say which one you want.

ListAsync reads only each file’s header (title, day, scene, the time it was saved and your own fields), which is why it is fast even with many slots. Every slot has a status. A damaged slot is still listed, with the reason, and CanLoad tells your menu whether to offer it.

With Recover From Backup on (the default), a load of a damaged slot reads the backup instead, with the warning LoadedFromBackup. The backup is tried only when the storage can keep backups (Caps.HasBackup) and the request did not set UseBackup. If the backup fails too, the result holds both reasons.

Setting Default What it does
Save Folder, Save Extension Intrigues Saves, .isav Where the files go and what they are called.
Autosave Slots 0 (off) How many slots the autosave ring turns through (auto-1, auto-2, and so on).
Autosave Prefix auto The name of those slots.
When Busy Queue A save, load or delete asked while another runs waits in line, or is refused.
Load Scene From Save Where a load without a request restores the game.
Encrypt, Encryption Password off, My Password See Encryption. Choose your own password.
Restore Order, On Missing Node, Resume By, New Definitions Per Actor, Drop, Index, Ignore What a load does when your database changed since the save: Loading after the database changed.

sources: field list and defaults in Runtime/Save/IntrigueSaveSystem.cs lines 14 to 175. The Inspector shows the field names as words. The component has more settings (Dice After Load, Unsaved Actors, Actor Wait Frames, Defer Inside Day, Pretty Print, Write Portrait Reference); this page does not describe them.

  • Asking for a save or load from another thread gives the status NotMainThread. Nothing is written.
  • With Encrypt on and no password, a save is refused with EncodeFailed before anything is captured.
  • On a multiplayer client, saves and loads are refused (RefusedOffHost): only the host saves.
  • A slot name may hold letters, digits, space, -, _ and ., up to 100 characters, with no dot or space at the start or end. Anything else gives InvalidSlot; the full rule is in Your own storage. “Slot” and “slot” are one save.