Vault Save System

Save & Load

The core API for reading and writing any supported value.

Signatures

static void Save<T>(string key, T value) static T Load<T>(string key, T defaultValue = default)

Load always returns defaultValue if the key doesn't exist — it never throws. Save writes immediately and is crash-safe via atomic file swap.

Primitives & Unity Types

// Primitives
Vault.Save("health",  100);
Vault.Save("speed",   5.5f);
Vault.Save("name",    "Hero");
Vault.Save("alive",   true);
Vault.Save("coins",   (long)1_000_000);
Vault.Save("pi",      3.14159265358979);   // double

// Unity types
Vault.Save("pos",  transform.position);   // Vector3
Vault.Save("rot",  transform.rotation);   // Quaternion
Vault.Save("tint", new Color(1, 0, 0));   // Color

// Collections and custom types
Vault.Save("items",  myList);             // List<T> where T is [Serializable]
Vault.Save("prefs",  myDictionary);       // Dictionary<string, T>
Vault.Save("config", myStruct);           // any [Serializable] struct or class

Other Operations

// Delete a key you no longer need
Vault.Delete("legacy_flag");

// Check if a key exists
bool has = Vault.Exists("score");

Use dotted keys like "Player.health" or "World.level" to stay organized and avoid collisions between systems.

Next Steps

Drawers
Multiple save slots.
Batch Mode
Flush many saves in one disk write.
Supported Types
Full list of all serializable types.