---
title: Game State Persistence
category: product
entity_type: skill
price: $15
canonical: https://forgehouse.ai/skills/game-state-persistence/
lang: en
hreflang_alt: https://forgehouse.ai/tr/skiller/game-state-persistence/
last_updated: 2026-06-20
---

# Game State Persistence

> Unity 6 game save/load system local file (JSON/MemoryPack binary), cloud sync (Apple…

A secure, versioned save/load system for Unity 6 games covering local files, cloud sync, schema migration, and optional anti-cheat encryption. It replaces the deprecated, RCE-prone BinaryFormatter with zero-alloc MemoryPack or readable JSON, adds AES-256-GCM plus HMAC integrity, and recovers from corruption through checksums and backup rotation. Cross-device sync ships for Apple GameCenter, Google Play Games, and Steam with explicit conflict resolution.

## Use cases
- Persisting character level, inventory, and quest progress across sessions
- Syncing save data across devices via iCloud, Play Games, or Steam Cloud
- Migrating save schemas safely when a game update adds or renames fields
- Encrypting saves to block resource-hack cheating
- Recovering gracefully from a corrupted save instead of crashing or starting over
- Throttling autosave to stop frame drops from frequent writes

## Benefits
- Protect players from progress loss: the single biggest driver of game churn
- Close a real RCE security hole by retiring BinaryFormatter for safe serialization
- Keep saves fast and small with zero-alloc binary that cuts cloud bandwidth
- Make cross-device handoff trustworthy with conflict dialogs instead of silent data loss

## What’s included
- Atomic save pipeline with MemoryPack, AES-256-GCM encryption, and HMAC signing
- Sequential schema-migration framework that never skips a version step
- Autosave throttling with debounce plus async writes that never block the main thread
- Cloud sync with timestamp and version-vector conflict resolution
- Crash-safe atomic file writes and backup rotation with corruption fallback
- Per-platform cloud API guidance for GameCenter, Play Games, and Steam

## Who it’s for
Unity game developers who need a robust, tamper-resistant, cross-device save system without the security and corruption risks of naive persistence.

## How it runs
Player progress has three enemies: crashes, cheaters and device switches. Saves get zero-alloc binary serialization, AES encryption with HMAC signatures, atomic writes with automatic backup fallback, and schema migrations that never skip a version.
1. Defines the GameSave schema with an explicit schemaVersion field and serializes it with MemoryPack (zero-alloc binary, roughly 3-5x faster than JSON). BinaryFormatter is banned outright: Microsoft deprecated it and it carries a remote code execution risk through untrusted save files.
2. Wraps the payload in defense layers: AES-256-GCM encryption for content, then an HMAC-SHA256 signature so a tampered or hand-edited save is rejected before deserialization, with the HMAC compared in constant time.
3. Writes atomically: payload goes to a .tmp file, gets flushed to disk, then renames over the live save while the previous file rotates into a backup. A crash mid-write leaves either the full old save or the full new one, never a half-written file.
4. On load, verifies HMAC and parses; if the primary save is corrupt it falls back to the backup automatically and tells the player a previous backup was restored. Silently starting a new game is forbidden.
5. Migrates schemas strictly in sequence: a v1 save passes through v1-to-v2 then v2-to-v3, each step filling new fields with defaults. Skipping a migration step is banned because it loses data.
6. Debounces autosave with a 5-second quiet window and async writes so saving never blocks a frame, and resolves cloud sync conflicts by timestamp; when timestamps tie, the player chooses between devices in a dialog because automatic merging risks losing real progress.

## FAQ
### My game ships on Steam and mobile, does cloud sync cover both?
Yes. It includes per-platform guidance for Apple GameCenter, Google Play Games, and Steam Cloud, with explicit conflict resolution based on timestamps and version vectors instead of silent overwrites.

### Couldn't I just roll my own save system with PlayerPrefs or JSON files?
For trivial data, sure. What this adds is the failure handling that bites later: atomic writes, checksum-based corruption recovery with backup rotation, sequential schema migration, and AES-256-GCM with HMAC integrity, while steering you away from the deprecated, RCE-prone BinaryFormatter.

### Does encryption make saves completely cheat-proof?
No. AES-256 plus HMAC blocks casual save-file editing, but a determined attacker on their own device can always dig deeper. Server-authoritative validation sits outside this package's scope.

## Price
$15, one-time, no subscription. VAT included.

Related guide: [A 2.5D isometric game-dev AI workflow with Unity](https://forgehouse.ai/guides/unity-isometric-ai-workflow/)
