Settings & Events
VaultSettings
Create a VaultSettings asset via Vault ▸ Create Settings.
Place it in any Resources/ folder and name it exactly VaultSettings.
| Property | Default | Description |
|---|---|---|
atomicWrites | true | Write via a temp file and atomic swap — prevents data loss on crash. Keep this on. |
enableCompression | false | GZip-compress save files. Typically 60–80% smaller. Old uncompressed files still load. |
enableEncryption | false | AES-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
| Event | When it fires |
|---|---|
Vault.OnSaved | After every successful write (sync or async). |
Vault.OnLoaded | After every successful read. |
Vault.OnDrawerChanged | Whenever the active drawer changes. Provides from/to names. |
Vault.OnSaved += key => Debug.Log($"Saved: {key}");
Vault.OnDrawerChanged += (from, to) => Debug.Log($"Drawer: {from} → {to}");