ScriptableObjects & MonoBehaviours
ScriptableObjects
Scans all [Save]-marked fields and persists them in one call. The key is a namespace
prefix — fields are stored as "key.TypeName.fieldName".
static void Save(string key, ScriptableObject so) static void Load(string key, ScriptableObject so) static Task SaveAsync(string key, ScriptableObject so) [CreateAssetMenu]
public class GameSettings : ScriptableObject
{
[Save] public bool musicEnabled = true;
[Save] public float masterVolume = 0.8f;
}
Vault.SetDrawer("settings");
Vault.Save("settings", myGameSettings);
Vault.Load("settings", myGameSettings);
await Vault.SaveAsync("settings", myGameSettings); // async variant MonoBehaviours
The builder overload saves all [Save]-marked fields on the MonoBehaviour automatically,
plus any Unity components you add with .With<T>(). Only what you list is included — nothing is saved implicitly.
static void Save(string key, MonoBehaviour mb, Action<VaultBuilder> build) static void Load(string key, MonoBehaviour mb, Action<VaultBuilder> build) // [Save] fields on the MonoBehaviour are included automatically.
// .With<T>() adds Unity components (Transform, Rigidbody, Camera, etc.)
Vault.Save("player", this, b => b.With<Transform>().With<Rigidbody>());
Vault.Load("player", this, b => b.With<Transform>().With<Rigidbody>()); Keys are stored as "player.YourComponent" per component and "player.YourMonoBehaviour" for the root script's [Save] fields.