Skip to content

Autosave

namespace Griff.Scenes;
public sealed class Autosave : Component

Saves the game by itself while its scene is played, in a slot of its own (“Auto”) that a Continue button loads like any other saved game, it being the latest: as the scene starts (a checkpoint as the player arrives), every few minutes of play, and as the game is closed. One anywhere in the scene is enough; put one in each scene that’s played (a prefab does), and none on the title screen or in menus, so Continue never goes back to them.

It saves as Game.SaveGame does, so the game saved is the same, and loading it doesn’t save it again as it starts. Minutes are of game time, so they don’t pass while the game is paused. Not in a network game.

This is a component: its saved properties are on its component page.

public float EveryMinutes { get; set; }

Minutes of play between saves (game time: not while paused). 0 saves only as the scene starts and as the game closes.

public bool OnArrive { get; set; }

Saves as its scene starts, once its scripts have: a checkpoint as the player arrives (not when a saved game is loaded).

public bool OnQuit { get; set; }

Saves as the game is closed (or, in the editor, as Play is stopped).

public string? Setting { get; set; }

A name in Game.SaveData that turns it off while it’s false: the player’s own switch, a Toggle with this Save As on the options screen (“settings.autosave”, kept by New Game). Empty is always on.

public string? Slot { get; set; }

The slot it saves in: “Auto” unless you name another.