Vault Save System

Settings & Events

VaultSettings

Create a VaultSettings asset via Vault ▸ Create Settings. Place it in any Resources/ folder and name it exactly VaultSettings.

PropertyDefaultDescription
atomicWritestrueWrite via a temp file and atomic swap — prevents data loss on crash. Keep this on.
enableCompressionfalseGZip-compress save files. Typically 60–80% smaller. Old uncompressed files still load.
enableEncryptionfalseAES-256 encrypt save files on disk.
encryptionKey"change-me-…"Passphrase for encryption. Change before shipping.

Encryption is not backward-compatible. If you enable it after players already have saves, those saves will fail to load. Plan from the start.

Change the default encryption key before shipping. Never ship with "change-me-before-shipping".

Override Settings in Code

// Useful for tests or temporary overrides
VaultSettings custom = ScriptableObject.CreateInstance<VaultSettings>();
custom.enableCompression = true;
custom.enableEncryption  = VaultSettings.Instance.enableEncryption;  // always mirror!
custom.encryptionKey     = VaultSettings.Instance.encryptionKey;
VaultSettings.SetInstance(custom);

// ... do work ...

VaultSettings.SetInstance(null);  // revert to asset

Events

EventWhen it fires
Vault.OnSavedAfter every successful write (sync or async).
Vault.OnLoadedAfter every successful read.
Vault.OnDrawerChangedWhenever the active drawer changes. Provides from/to names.
Vault.OnSaved         += key => Debug.Log($"Saved: {key}");
Vault.OnDrawerChanged += (from, to) => Debug.Log($"Drawer: {from} → {to}");