Async API
Offloads disk I/O to a background thread so the main thread never stalls. Serialization still happens on the calling thread (Unity-API safe).
API
static Task SaveAsync<T>(string key, T value) static Task<T> LoadAsync<T>(string key, T defaultValue = default) static Task SaveAsync(string key, ScriptableObject so) Usage
// In an async method
async void OnCheckpoint()
{
await Vault.SaveAsync("pos", transform.position);
await Vault.SaveAsync("hp", health);
}
async void Start()
{
health = await Vault.LoadAsync<float>("hp", 100f);
position = await Vault.LoadAsync<Vector3>("pos");
}
// Save a ScriptableObject asynchronously
await Vault.SaveAsync("settings", myScriptableObject); In Unity's Edit Mode test runner, async Task tests aren't supported. Use .GetAwaiter().GetResult() to block synchronously in tests.
Don't fire concurrent async saves to the same drawer simultaneously — await each one before starting the next, or use BeginBatch + EndBatch.