1. Prepare a server
Cloud sync is optional. Local saving works without it. To sync between devices, host the included PHP 8.3+ / SQLite server or ask your server administrator to set it up.
Follow the server setup manual. You need one host with PDO SQLite and mbstring, HTTPS outside localhost, and a backup plan. WebGL builds also need the game's origin allowed in the server's CORS settings.
The package includes server code. It does not include a hosted cloud service.
2. Connect your player
- Set the server URL, application identifier, and cloud slot in the configurator.
- Add
CloudSaveManagerto the scene. - Connect with the player's credentials.
- Wait for successful login, then synchronize.
CSS.Web.CloudSaveManager.GetInstance()
.CloudConnect(userName, password, displayName);
// Call this after login succeeds.
SaveResult result = await SaveSystem.CloudSyncAsync();
Check result.Succeeded before showing a success message. See login completion events to wait for the connection.
Advanced: authentication
The configured application identifier selects the game deployment; it is not player authorization. Login sends a password-equivalent credential hash over HTTPS and obtains an expiring session token. Hashing does not replace HTTPS.
3. Decide what to tell the player
Sync compares changes since the last successful synchronization:
| What changed? | What happens? |
|---|---|
| Only this device | Upload its progress. |
| Only the server | Check and download the server's progress. |
| Both | Use the newest server revision. Keep this device's displaced save as a recovery copy. |
| A cloud save was deleted | Remember the deletion so an old device cannot silently bring it back. |
When both changed, tell the player that server progress was selected. Subscribe to this event to receive the local recovery file's path:
private void OnEnable() => CSS.Web.IOWeb.ConflictRecovered += Recovered;
private void OnDisable() => CSS.Web.IOWeb.ConflictRecovered -= Recovered;
private void Recovered(string path) =>
UnityEngine.Debug.Log("Server progress selected. Local recovery copy: " + path);
Advanced: revisions and safe downloads
Conflicts use server revisions and the last synchronized state, rather than device clocks or file timestamps. Uploads include the expected server revision. Downloads are validated before replacing the local save.
4. Handle a lost connection
Let the player keep using local saves while offline. Call synchronization again after the connection returns. If the session has expired, log in again first.
The client remembers pending synchronization, but does not run an automatic background reconnect service. Players also need to log in again after restarting the application.
Advanced: retries and session lifetime
Transient failures use bounded retries and timeouts. Pending work and the last synchronized revision are stored beside the save. Credentials and session tokens remain in memory. Logout can revoke a session.
5. Test with two devices
Change progress separately on two clients, sync them, and check the selected save and recovery copy. Also test loss of connection, expired login, and full storage before releasing your game.
Advanced: deployment checks
Validate invalid downloads, quotas, deletion, database restoration, and real Unity HTTPS/CORS behavior. Automated managed/server checks do not replace multi-device testing.