Crash-safe, account-scoped save data for Unity, with optional cloud sync.
Player progress is written through a temp file, an fsync and a rename, with a .bak copy kept, so a
crash or a battery death in the middle of a write cannot leave a half-written save. Each account,
guest session and named local profile gets its own folder, so signing in and out never mixes two
players' data. Data classes carry a schema version and an upgrade hook, so shipping a new build over
an old save is a normal, tested operation instead of a silent wipe.
Cloud sync is optional and provider-agnostic: a CloudSync slot is reconciled by write-id
provenance, never by "last write wins", and the package will refuse an unsafe overwrite rather than
destroy a copy of the data it cannot prove it owns.
| Unity | 6000.0 or newer. |
| UniTask | Required. Install it before this package; a git-URL package cannot declare it as a dependency. |
Newtonsoft Json (com.unity.nuget.newtonsoft-json 3.2.1+) |
Required; resolved automatically. |
| Zenject / Extenject | Optional, for the DI integration. |
| Unity Gaming Services Cloud Save 3.0.0+ | Optional, for the bundled cloud provider. |
Supported platforms: Android, iOS, Windows, macOS, Linux, and the Editor on desktop. WebGL is not supported in 0.1.0.
Package Manager → Add package from git URL:
https://github.com/ecanakli/UnitySaveSystem.git#v0.1.1
Or add the line to Packages/manifest.json:
"com.ecanakli.savesystem": "https://github.com/ecanakli/UnitySaveSystem.git#v0.1.1"Always install a tag. Without #v0.1.1 the install tracks the default branch.
No DI container
- Reference
Ecanakli.SaveSystemfrom your game's assembly definition. - Construct
SaveServiceyourself. The quick start below is the whole thing.
Zenject/Extenject installed under Assets/
- Reference
Ecanakli.SaveSystemandEcanakli.SaveSystem.DependencyInjection.Zenject. - Enable
Tools/Save System/Zenject Integration(it sets a scripting define on every build target) and commitProjectSettings. - Install
SaveServiceInstallerin your project installer. See Dependency injection.
Extenject installed as a UPM package
Same as above, but skip step 2: the integration assembly turns itself on through versionDefines.
public sealed class PlayerData
{
public int Level { get; set; } = 1;
public long Coins { get; set; }
}
public sealed class PlayerSlot : SaveSlot<PlayerData>
{
public override string Key => "player";
}
// Bootstrap, once.
var options = new SaveServiceOptions();
var slot = new PlayerSlot();
ISaveService save = new SaveService(
options,
new AtomicFileStorage(options.RootDirectory),
NullCloudSaveProvider.Instance,
new SaveSlot[] { slot });
IDisposable lifecycle = SaveLifecycleDriver.Attach(save);
await save.InitializeAsync(ct);
// Anywhere in gameplay.
long coins = slot.Read(static data => data.Coins);
slot.Mutate(100, static (data, amount) => data.Coins += amount);
// Purchases and rewards wait for the bytes to land.
await slot.SaveNowAsync(ct);- Start here — what it does, how a game saves, the API map, platforms and limits
- Slots and profiles — declaring slots, hooks, profiles, account switching
- Sync and recovery — uploads, conflicts, corruption, OS backups, Steam
- Events and listeners — the six events and the two listener interfaces
- Schema changes — versioning save data and the Editor guard
- Dependency injection — the Zenject integration
- Unity Cloud Save — enabling the UGS provider
- Troubleshooting — symptoms and fixes
MIT. See LICENSE.md.