Unity Save System Guide: PlayerPrefs, JSON & Cloud Saves
Imagine playing a simulation game for several hours.
You’ve unlocked new equipment, earned in-game currency, completed multiple levels, and customized your environment.
Everything works perfectly until you close the game.
When you launch it again, your progress has disappeared.
Your unlocked items are gone, the currency balance has reset, and the game starts from the beginning.
For players, losing progress can be extremely frustrating.
For developers, it can indicate a serious problem with the game’s data management system.
A reliable Unity save system is therefore an important part of developing games that contain persistent progression.
But Unity developers have several options for storing player data.
Should you use PlayerPrefs?
Is JSON better for saving complex game progress?
When should you introduce cloud saves?
And how can you prevent corrupted files or lost progress after a game update?
This guide explains the differences between PlayerPrefs, JSON-based save files, and cloud storage, along with practical recommendations for Android, PC, and Steam games.
1. What Is a Save System in Unity?
A save system allows a game to preserve important information between gameplay sessions.
When the player closes the application, selected data is stored.
When the game launches again, the saved information is loaded so the player can continue.
What Information Should a Game Save?
The exact requirements depend on the game’s design.
A racing game might save unlocked vehicles, completed races, upgrade levels, and player currency.
A supermarket simulator might preserve inventory quantities, purchased equipment, shop upgrades, and completed objectives.
An adventure game may require player position, mission progress, inventory items, and world-state changes.
Not every piece of information needs permanent storage.
Temporary effects, current animation states, and other short-lived data can often be reconstructed when the game loads.
Separate Game State From Save Data
A useful development practice is to distinguish the complete runtime game state from the smaller set of information required to restore progress.
For example, a game doesn’t necessarily need to save the position of every decorative object.
Instead, it may only need to store which objects were purchased or placed.
This keeps save data focused and easier to maintain.
2. PlayerPrefs vs. JSON vs. Cloud Saves
Before implementing a save system, understand what each approach is designed to accomplish.
| Feature | PlayerPrefs | JSON Save Files | Cloud Saves |
|---|---|---|---|
| Primary Purpose | Simple preferences | Structured local game data | Remote player data |
| Storage Location | Device-managed local storage | Local files | Remote service |
| Complex Data | Limited native value types | Supported serializable structures | Depends on service and data model |
| Offline Access | Yes | Yes | Requires a local strategy for offline use |
| Cross-Device Sync | Not built in | Not built in | Possible with appropriate integration |
| Implementation Complexity | Low | Moderate | Moderate to high |
| Typical Use | Audio settings, language preferences | Progression, inventory, checkpoints | Account-linked progress and synchronization |
These approaches are not necessarily mutually exclusive.
A game can use PlayerPrefs for simple settings, JSON files for local progress, and cloud storage for supported synchronization features.
The important decision is determining which data belongs in each system.
3. When Should You Use PlayerPrefs?
Unity provides a built-in PlayerPrefs API for storing simple values between sessions.
It supports integers, floating-point numbers, and strings.
For example, developers can use PlayerPrefs to remember the player’s selected language or audio volume.
Example: Saving Audio Settings
A simple Unity implementation might look like this:
PlayerPrefs.SetFloat("MusicVolume", 0.75f);
PlayerPrefs.Save();
To retrieve the value:
float volume = PlayerPrefs.GetFloat("MusicVolume", 1f);
The second parameter provides a default value when the key doesn’t exist.
Why PlayerPrefs Has Limitations
PlayerPrefs isn’t intended to be a complete save-game database.
It doesn’t directly provide structured storage for complex inventories, quest systems, or interconnected gameplay data.
Unity also states that PlayerPrefs data is stored without encryption.
Therefore, it should not be used to store passwords, authentication secrets, or other sensitive information.
The official Unity PlayerPrefs documentation confirms its supported value types and storage limitations. Unity Docs
Practical recommendation: Use PlayerPrefs for straightforward preferences rather than relying on it as the primary storage system for complex game progression.
4. When Should You Use JSON Save Files?
JSON is a text-based format commonly used to represent structured information.
In Unity, developers can serialize supported C# objects into JSON and save them to a file.
This approach is useful when a game needs to preserve several related values.
Example: Racing Game Progress
Consider a hypothetical racing game containing unlocked vehicles, player currency, and completed levels.
A simplified JSON save might look like this:
{
"saveVersion": 1,
"playerCoins": 2500,
"unlockedLevel": 8,
"selectedCar": 3,
"musicEnabled": true
}
The game can read these values when loading the player’s progress.
Using Unity JsonUtility
Unity provides JsonUtility.ToJson() and JsonUtility.FromJson() for serializing supported objects.
For example:
[System.Serializable]
public class GameSaveData
{
public int saveVersion = 1;
public int playerCoins;
public int unlockedLevel = 1;
public int selectedCar;
}
A developer can convert an instance into JSON:
string json = JsonUtility.ToJson(saveData);
And restore supported data:
GameSaveData loadedData =
JsonUtility.FromJson<GameSaveData>(json);
Unity’s serializer has specific rules concerning supported fields and data types.
For example, dictionaries aren’t directly supported by JsonUtility, and unsupported fields may be omitted during serialization.
Review the official Unity JSON serialization documentation when designing more complex save structures. Unity Docs
These examples demonstrate serialization only. A production save system also needs reliable file handling, validation, and error recovery.
5. Where Should Unity Save Game Files?
Choosing the correct storage location is essential.
Developers should avoid assuming that files can be written anywhere inside the installed game directory.
Unity provides Application.persistentDataPath for storing data intended to remain available between application sessions.
Example Save File Path
using System.IO;
using UnityEngine;
string savePath = Path.Combine(
Application.persistentDataPath,
"savegame.json"
);
The resulting location depends on the operating system.
On Windows, Unity commonly uses a location beneath the user’s AppData/LocalLow directory.
On Android, it uses an application-specific storage location.
The official Application.persistentDataPath documentation describes the platform-specific behavior. Unity Docs
Why Storage Paths Matter
A game may work correctly inside the Unity Editor but fail when installed on another device if it relies on incorrect file paths.
Always test saving and loading in an actual build.
Also verify that application updates preserve access to the intended save location.
Uninstalling an application, clearing its data, or changing its identity may affect local save availability depending on the platform.
6. Design the Save Data Structure Before Programming
A common development mistake is implementing save functionality separately inside every gameplay script.
For example, the shop system might save currency while the level manager independently saves progression.
This can create inconsistent states.
Use a Central Save Manager
A better approach is to define a clear save-data model and coordinate persistence through a dedicated system.
Gameplay components can update the runtime state while the save manager handles serialization and storage.
This also makes it easier to introduce backups or cloud synchronization later.
Use Stable Identifiers
Imagine a supermarket simulator containing dozens of products.
Saving inventory using the temporary order of objects in a scene can be risky.
If objects are rearranged during development, saved references may no longer identify the correct items.
Instead, use stable identifiers for products, upgrades, levels, and other persistent entities.
For example, an inventory entry could reference a product identifier such as PRODUCT_MILK_01.
The exact identifier format matters less than keeping it stable across compatible game versions.
7. When Should a Game Save Progress?
Saving only when the player exits the application is risky.
Mobile operating systems can suspend or terminate applications, and crashes can occur unexpectedly.
Use Meaningful Save Points
A racing game might save after completing a race, purchasing an upgrade, or unlocking a vehicle.
A simulation game might save after major inventory transactions or completed objectives.
Autosave intervals can also be useful.
However, writing large files too frequently may create unnecessary storage operations.
Save Consistent Game States
Imagine awarding coins before updating the completed-level record.
If the application closes between those operations, the saved data may become inconsistent.
Where possible, update the complete relevant game state before writing a save.
The goal is to preserve a valid progression snapshot rather than several unrelated partial updates.
8. How to Prevent Save File Corruption
A reliable save system must consider what happens when something goes wrong.
The application might close unexpectedly while writing a file.
Storage may become unavailable, or previously saved data may be malformed.
Use Temporary Files and Backups
A common strategy is to write new data to a temporary file before replacing the active save.
After the new file has been written and validated, the application can replace the previous version using a platform-appropriate strategy.
Maintaining a backup of the last known valid save can provide another recovery option.
The exact implementation should account for filesystem behavior and supported platforms.
Validate Loaded Data
Never assume that successfully reading a file means its contents are valid.
Check the expected version, required fields, value ranges, and relevant relationships.
For example, a negative level number or an invalid inventory identifier may indicate corrupted or incompatible data.
If loading fails, avoid immediately overwriting the original file with a new empty save.
Preserve recoverable data where possible.
9. Prepare Save Systems for Future Game Updates
Games often change after release.
Developers may introduce new levels, inventory systems, currencies, or gameplay mechanics.
These changes can affect the structure of saved data.
Why Save Versioning Matters
Imagine releasing a game with this information:
saveVersion = 1
Later, an update introduces additional vehicle upgrades and progression fields.
The new version of the game must understand how to interpret older save files.
Introduce Data Migration
A migration system converts supported older save formats into the structure expected by the current game.
For example, a version-one save might contain only player currency and unlocked levels.
A version-two save could introduce an upgrade inventory.
The migration process can preserve the existing values while initializing the new fields appropriately.
Always test migration using genuine save files produced by previous builds.
Avoid assuming that changing the C# data class automatically provides a safe migration.
10. When Should You Use Unity Cloud Save?
Local saves work well for many offline games.
However, some projects need player progress to remain accessible across multiple devices.
This is where cloud storage becomes useful.
Unity provides Cloud Save through Unity Gaming Services.
It supports storing player-associated data remotely.
Example: Cross-Device Progress
Imagine a player beginning a game on one Android device and later using another.
With a properly implemented account-linked cloud save system, the game may be able to restore the player’s progress.
However, this requires more than simply uploading a JSON file.
Developers must consider player identity, authentication, synchronization, offline behavior, and conflicting changes.
Handle Conflicting Saves
What happens if a player makes progress on two devices while one is offline?
Both devices may contain valid but different save states.
A synchronization system needs a defined conflict-resolution policy.
Unity Cloud Save supports write locks that can help detect conflicting updates.
Developers can then decide whether to merge data, ask the player to choose, or apply another appropriate strategy.
The official Unity Cloud Save documentation and write-lock guide explain these capabilities. Unity Docs
Important: Cloud storage is not automatically a backup or recovery guarantee. Authentication, synchronization, retention, and conflict handling must be implemented and tested.
11. How Do Save Systems Work With Steam Cloud?
For PC games distributed through Steam, developers can consider Steam Cloud.
Steam Cloud can synchronize supported game files between computers associated with a player’s Steam account.
Steam Auto-Cloud vs. Cloud API
Steam offers two main approaches.
Steam Auto-Cloud can synchronize configured file paths without requiring direct Cloud API integration.
The Steam Cloud API provides additional control over how files are managed.
Developers must configure the relevant functionality through Steamworks.
Steam Cloud doesn’t automatically synchronize every file a Unity game creates.
Test Cross-Computer Synchronization
A useful test involves saving progress on one PC, closing the game, allowing synchronization to finish, and then launching it on another computer.
Verify that the expected progress loads correctly.
Also test interrupted synchronization and conflicting save files.
The official Steamworks Steam Cloud documentation includes configuration guidance and a Unity Auto-Cloud example. Steamworks
For broader PC release preparation, review our Steam game release checklist for Unity developers.
12. Protect Important Player Data
Not every value stored on a player’s device should be trusted.
Local save files may be modified, copied, or replaced.
This becomes particularly important when a game includes competitive rankings, valuable virtual items, or online economies.
Separate Local Convenience From Server Authority
For an offline single-player game, local progression may be sufficient.
For a competitive multiplayer game, important rewards and economy transactions may require server-side validation.
Encrypting a local file doesn’t automatically make client-controlled data trustworthy.
If the client can generate or modify authoritative rewards, determined users may still manipulate the results.
For systems requiring stronger integrity, use an appropriate server-authoritative architecture.
Our Unity multiplayer game development guide explores related networking and authority considerations.
13. Test the Save System Before Release
Save functionality should receive dedicated quality-assurance testing.
A game may appear stable during normal gameplay but fail when players encounter unusual conditions.
Test Realistic Scenarios
Begin a new game, save progress, close the application, and reopen it.
Then test multiple save slots if the game supports them.
Check what happens when the application closes unexpectedly.
Verify that purchases, upgrades, unlocked levels, and achievements remain consistent.
Test malformed save data, missing files, interrupted writes, and migration from older versions.
For cloud-enabled games, include offline sessions, authentication changes, and synchronization conflicts.
Test Actual Devices
Android and PC builds can behave differently from the Unity Editor.
Always verify persistence using representative devices and operating systems.
For mobile projects, save operations should also be reviewed alongside performance testing.
Our Unity mobile game optimization guide covers additional considerations for maintaining responsive gameplay.
Practical Example: Save System for a Unity Supermarket Simulator
Consider a hypothetical supermarket simulation game.
The player manages inventory, purchases shelves, unlocks equipment, and earns currency.
The development team needs to preserve this information between sessions.
A practical architecture could use PlayerPrefs for audio and graphics preferences.
A structured local save file could store inventory quantities, unlocked equipment, shop upgrades, and player progression.
The save manager could create a consistent snapshot after important transactions.
For a PC release, Steam Cloud might synchronize eligible save files between supported computers.
If the game later introduces online accounts, a separate cloud-data strategy could be evaluated.
The team would also need to plan for future updates that introduce new products or gameplay systems.
This example demonstrates a possible architecture, not a claim about any specific released project.
Common Unity Save System Mistakes to Avoid
A common mistake is using PlayerPrefs as the complete storage solution for a complex game.
Another is saving important progress only when the application exits.
Developers may also overlook data validation, backups, and save-file versioning.
Cloud synchronization can introduce additional problems when conflicting progress is overwritten without an appropriate policy.
Finally, testing only in the Unity Editor may leave platform-specific issues undiscovered.
The best save system is not necessarily the most complicated one.
It is the system that reliably supports the game’s actual requirements.
Conclusion
A reliable Unity save system protects one of the most important parts of the player experience: progress.
PlayerPrefs is suitable for simple preferences.
JSON-based local files provide a flexible approach to structured game data.
Cloud saves can support remote persistence and cross-device synchronization when properly implemented.
However, choosing a storage format is only the beginning.
Developers must also consider save timing, data validation, backup strategies, version migration, security, and platform-specific testing.
Planning these requirements early can reduce avoidable problems during development and after release.
At GamePro Studio, our services include Unity game development, custom gameplay systems, and mobile and PC game production.
Explore our Unity game development services or game development portfolio to learn more about our work.
If you’re developing a new game or improving an existing Unity project, you can contact GamePro Studio to discuss your requirements.
Frequently Asked Questions
1. What is the best way to save game progress in Unity?
There is no universal solution. PlayerPrefs is useful for simple settings, while JSON or another structured storage format is generally more suitable for complex local progression. Cloud storage may be appropriate when the game requires account-linked data or cross-device synchronization.
2. Is PlayerPrefs safe for saving player currency?
PlayerPrefs can technically store currency values, but it doesn’t provide encryption or protection against local modification. For offline games, the risk may be acceptable depending on the design. Competitive or server-controlled economies generally require stronger validation.
3. Can Unity save game progress without an internet connection?
Yes. PlayerPrefs and local save files can operate offline. Cloud-enabled games can also support offline play, but developers must implement appropriate local caching and synchronization behavior.
4. How can I prevent players from losing progress after an update?
Maintain stable storage locations, introduce save-file versioning, implement migrations when data structures change, and test upgrades using actual save files from previous releases. Backups and recovery procedures can provide additional protection.
5. Does Steam Cloud automatically work with Unity games?
No. Developers must configure Steam Cloud for their game. Steam Auto-Cloud can synchronize specified file paths, while the Steam Cloud API provides more direct control. The integration must be tested before advertising cloud-save support.