Configure PersistlyGameSaves during boot with the Unity settings asset or startup code.
Unity Templates
Unity templates for one-save, slots, and account restore.
Use PersistlyGameSaves from Unity gameplay code first. Start with SaveDataAsync for one current save, move to SaveSlotAsync for named slots, and restore known account sessions through AttachAccountAsync when your own sign-in flow is ready.
One Save
Unity one-save starter
When to use this: Use this for Unity games that need one durable autosave path first.
Unity starter
Unity one-save starter
Copy this into your game-facing save service, then adapt the data type and safe sync moments to your game.
using Persistly.Unity;
using UnityEngine;
public sealed class SaveService : MonoBehaviour
{
public async void Save(GameState state)
{
await PersistlyGameSaves.Shared.SaveDataAsync(state);
}
public async void Load()
{
var loaded = await PersistlyGameSaves.Shared.LoadDataAsync<GameState>();
if (loaded.Found && loaded.Data != null)
{
ApplyData(loaded.Data);
}
}
public async void SyncCheckpoint()
{
await PersistlyGameSaves.Shared.ForceSyncDataAsync();
}
}Save normal gameplay state with SaveDataAsync.
Force-sync from checkpoint, pause, or manual-save moments.
Read the SDK setup, behavior, and facade guidance for this engine.
Open SDK docsDetailed guideOpen the matching SDK guide for save, load, sync, and account restore details.
Open guideTemplate folderOpen the public SDK repository folder for the complete copy-paste template when it is published.
Open GitHubMultiple Slots
Unity multiple-slot starter
When to use this: Use this for manual saves, campaigns, and character select screens in Unity.
Unity starter
Unity multiple-slot starter
Copy this into your game-facing save service, then adapt the data type and safe sync moments to your game.
using Persistly.Unity;
using UnityEngine;
public sealed class SlotSaveService : MonoBehaviour
{
public async void SaveSlot(string slotId, GameState state)
{
await PersistlyGameSaves.Shared.SaveSlotAsync(slotId, state, new PersistlySaveSlotOptions
{
SlotInfoJson = "{"label":"" + slotId + ""}"
});
}
public async void LoadSlot(string slotId)
{
var loaded = await PersistlyGameSaves.Shared.LoadSlotAsync<GameState>(slotId);
if (loaded.Found && loaded.Data != null)
{
ApplyData(loaded.Data);
}
}
public async void SyncSlot(string slotId)
{
await PersistlyGameSaves.Shared.ForceSyncAsync(slotId);
}
}Use stable slot ids your game owns, not display names that change often.
Keep save-menu labels, playtime, and preview data in SlotInfoJson.
Sync only the slot the player changed unless your lifecycle calls for due sync.
Read the SDK setup, behavior, and facade guidance for this engine.
Open SDK docsDetailed guideOpen the matching SDK guide for save, load, sync, and account restore details.
Open guideTemplate folderOpen the public SDK repository folder for the complete copy-paste template when it is published.
Open GitHubAccount + Slots
Unity account + slots starter
When to use this: Use this when Unity account restore is backed by your own trusted sign-in system.
Unity starter
Unity account + slots starter
Copy this into your game-facing save service, then adapt the data type and safe sync moments to your game.
using Persistly.Unity;
using UnityEngine;
public sealed class AccountSlotService : MonoBehaviour
{
public async void ExportSessionForBackend()
{
var session = PersistlyGameSaves.Shared.GetAccountSession(includeToken: true);
SendToYourBackend(session.AccountId, session.AccountSessionToken);
}
public async void RestoreAccount(string accountId, string accountSessionToken)
{
await PersistlyGameSaves.Shared.AttachAccountAsync(accountId, accountSessionToken);
}
public async void SaveSignedInSlot(string slotId, GameState state)
{
await PersistlyGameSaves.Shared.SaveSlotAsync(slotId, state, new PersistlySaveSlotOptions
{
SlotInfoJson = "{"label":"" + slotId + ""}"
});
await PersistlyGameSaves.Shared.ForceSyncAsync(slotId);
}
}Treat accountSessionToken as a sensitive restore credential in your own account system.
Call AttachAccountAsync before loading a signed-in player's slots on a new device.
Keep gameplay code on SaveSlotAsync and ForceSyncAsync after account restore.
Read the SDK setup, behavior, and facade guidance for this engine.
Open SDK docsDetailed guideOpen the matching SDK guide for save, load, sync, and account restore details.
Open guideTemplate folderOpen the public SDK repository folder for the complete copy-paste template when it is published.
Open GitHub