# 1. UGS Project and Local-First Saves
Part of [[Cloud Save and Unity Services]]. Next: [[2. Authentication Bootstrap]].
Cloud Save is a **service**, not a replacement for `Application.persistentDataPath`. If the cafeteria Wi-Fi dies mid-save, the player still needs a file on disk.
## 1.1 Local-first, cloud-as-mirror
[[High Scores, Saves and Player Stats]] already:
- Writes a **versioned JSON slot** atomically (temp file, then replace, with a `.bak`).
- Stores `savedUtcTicks` (or equivalent) on the slot so two copies can be compared.
- Offers optional Part 4 `CloudSaveMirror`: upload the same JSON string under a key such as `slot_0`, and on startup compare ticks and **ask** which copy to keep.
This series keeps that contract:
1. **Save:** write the local file first. Only if that succeeds, try to upload the same bytes/string. If the upload throws, log it, surface a non-blocking "cloud sync failed" if you want, and leave the local file alone.
2. **Load:** load local first so the game can start offline. Then, if signed in and online, fetch the cloud copy and compare `savedUtcTicks` (or another field you already trust). If they differ, **ask** - never silently overwrite.
3. **One schema.** The cloud value *is* the slot JSON. Do not invent a second "cloud DTO" that can drift.
PlayerPrefs may still hold tiny settings ([[PlayerPrefs Advanced]]); they are not the campaign slot and they are not a Cloud Save strategy.
## 1.2 Project and dashboard
1. Open the Unity **6000.5** project that already has the High Scores save system (or a slice of it).
2. **Edit > Project Settings > Services**: select or create the Unity project. Confirm the Project ID.
3. In the **Unity Dashboard** for that project, enable **Authentication** and **Cloud Save**. Exact checkbox labels move; if save/load fails with a "service not enabled" / permissions error, this step is the cause - not `SaveAsync`.
4. Package Manager > Unity Registry:
- **Cloud Save** (`com.unity.services.cloudsave`) - official 6000.5 page: **3.4.2** released (3.4.0–3.4.2 listed). Pin what you test.
- **Authentication** (`com.unity.services.authentication`) - **3.7.4** released for 6000.5; **3.8.0 / 3.8.1** also listed. Often pulled in as a dependency; confirm the resolved version.
Free-tier limits and pricing change. Check the current UGS pricing / fair-use page for your org; this series does not quote a quota that will be stale next semester.
If the same project also uses [[Lobby, Relay and Multiplayer Services]], it should be the **same** Unity Project ID and the same `UnityServices.InitializeAsync` call. Do not initialize Services twice with different configs "to keep cloud and multiplayer separate."
## 1.3 What this series will not do
- Economy, IAP, Remote Config, or service-side Leaderboards. High Scores stays a **local table** that you may mirror.
- The Cloud Save **Files** API (binary files). 3.4.2 includes it; confirm method names in the Scripting API if you need it later. All worked examples use **Data.Player** key/value items.
- Inventing a Services Core package version.
- Treating an anonymous Player ID as a permanent account the student can recover after deleting player data / reinstalling without a cached token. Anonymous is fine for class; platform providers are a later, dashboard-configured step.
## 1.4 Exercise
Link the project, install Cloud Save 3.4.2 and confirm Authentication, and write a four-line policy at the top of the save class (or a `CLOUD_SAVE.md` in the project): local first, mirror after, compare ticks, never block on the network. You will implement it in parts 3–5.
## Sources
- Cloud Save 6000.5: https://docs.unity3d.com/6000.5/Documentation/Manual/com.unity.services.cloudsave.html
- [[High Scores, Saves and Player Stats]] Part 4