Skip to content

ISavesState

namespace Griff.Runtime;
public interface ISavesState

A script (a Behavior or a GameSystem) that writes its own model into a saved game rather than having its fields saved for it: SaveState writes what it wants kept, by name, and LoadState reads it back as the game is loaded (after the script’s Start, before its OnLoaded). Values are anything a script’s field can hold in a saved game: numbers, text, enums, vectors, plain objects and records, lists, arrays and dictionaries of them, and entities and components (kept as which they are). None of its fields are saved, so it saves all it needs.

public abstract void LoadState(SaveReader save)

Reads back what SaveState wrote, as the game is loaded. A game saved by an earlier build may not have a value, or have one of another kind: Get gives the fallback then.

public abstract void SaveState(SaveWriter save)

Writes what the script keeps in a saved game, as the game is saved.