OSL Secure Save
A UGS Cloud Save workflow for projects that want package API writes checked by Cloud Code before storage.
Clarification: OSL Secure Save is not a local encrypted save-file package. It is designed around Unity Cloud Save and Cloud Code based validation.
Table of Contents
- Overview
- Who Should Use This
- Requirements
- UGS Project Setup
- Unity Package Setup
- Basic Setup
- Using OSLSaveManager
- Demo Scene
- Troubleshooting
Overview
OSL Secure Save routes OSLSaveManager writes through osl_master_save, where per-key type, range, delta, and operation rules are checked before accepted values are stored. Reads use Cloud Save's Default access class directly.
Who Should Use This
Use OSL Secure Save when your project needs:
- Unity Cloud Save based player data storage
- Unity Cloud Code based write validation
- Per-key type, range, maximum delta, and allowed-operation rules
- Simple typed save helpers for common player data values
- A sample scene for checking the basic save flow
Requirements
| Requirement | Version |
|---|---|
| Unity | 2021.3 LTS or later |
| Tested Unity versions | 2021.3.45f2 and 6000.3.12f1 (package-isolation import and compile) |
| com.unity.services.cloudcode | 2.x or later |
| com.unity.services.cloudsave | 3.0.0 or later |
| com.unity.services.authentication | 2.x or later |
| com.unity.services.core | 1.x or later |
Remote Config is optional and is used for remotely managed rule JSON.
Validation applies to writes made through the package Cloud Code path. The included script writes to Cloud Save's Default access class; avoid or separately restrict direct client write paths. This package is not a complete anti-cheat system or a local save-file system.
UGS Project Setup
- Open Unity Dashboard.
- Create or select a project.
- Enable Cloud Code, Cloud Save, Authentication, and optionally Remote Config.
- In the Unity Editor, link your project via Edit → Project Settings → Services.
Unity Package Setup
- Search for OSL Secure Save in the Unity Asset Store, or open it directly at Unity Asset Store (OSL Secure Save).
- Click Add to My Assets.
- Open Unity and navigate to Window > Package Manager.
- Select Packages: My Assets from the dropdown.
- Locate OSL Secure Save, download it, and click Import.
Next, install the required UGS SDKs via Window → Package Manager → Unity Registry:
Authentication(com.unity.services.authentication)Cloud Code(com.unity.services.cloudcode)Cloud Save(com.unity.services.cloudsave)Remote Config(com.unity.services.remoteconfig) — optional
Basic Setup
- Configure your Unity Gaming Services project.
- Deploy the required Cloud Code script included with the package.
- Configure any validation data required by your project.
- Initialize Unity Services before using the save manager.
- Sign in through Unity Authentication before making save requests.
Using OSLSaveManager
Initialization
await UnityServices.InitializeAsync();
await AuthenticationService.Instance.SignInAnonymouslyAsync();
Write operations
OSLSaveResult result = await OSLSaveManager.Instance.AddInt("gold", 50);
await OSLSaveManager.Instance.SetInt("level", 5);
await OSLSaveManager.Instance.SetString("playerName", "Hero");
await OSLSaveManager.Instance.SetBool("tutorialDone", true);
Read operations
int gold = await OSLSaveManager.Instance.GetAsync<int>("gold", 0);
string name = await OSLSaveManager.Instance.GetAsync<string>("playerName", "Unknown");
Dictionary<string, object> all = await OSLSaveManager.Instance.LoadAllAsync();
Demo Scene
Assets/OSL/SecureSave/Demo/OSLBasicUsageSample.cs provides an interactive OnGUI demo.
- Create an empty scene and attach
OSLBasicUsageSampleto a GameObject. - Enter Play mode and use the on-screen buttons to test sign-in and sample save operations.
Troubleshooting
| Symptom | Likely cause | Action |
|---|---|---|
| Save operation fails immediately | Unity Services or Authentication is not initialized | Initialize Unity Services and sign in before using OSLSaveManager. |
| Cloud Save calls fail | UGS project setup is incomplete | Confirm the Unity project is linked to the correct UGS project. |
| Demo scene does not work | Required UGS packages are missing | Install the required Unity Services packages. |
| Compile errors after import | Dependency package is missing | Resolve Unity package dependencies and recompile. |