Skip to content

Saves

An demonstration of UPSPlayerPrefs: a grid of focusable elements, each bound to a different key/type (int, float, string, bool). Press Apply to mutate the value at the focused cell, watch the on-screen text refresh, then quit and re-open the scene - the values persist through the configured IFileSystem.

Scene Assets/UpscaleSDK/Samples/Saves/Saves.unity
Scripts SavesTest.cs, ErrorPopup.cs, PopupErrorHandler.cs
Prefab ErrorPopupPrefab.prefab
Saves sample

What it demonstrates

  • The full UPSPlayerPrefs surface - GetInt / SetInt, GetFloat / SetFloat, GetString / SetString, GetBool / SetBool
  • Gating reads / writes on UPSSaves.Prefs.IsReady
  • Driving a UI element from a UIElement's OnFocusChanged / OnInteracted events
  • Wiring an in-game popup to ErrorHandler.OnError so save failures actually surface to the player

How to run

  1. Open Saves.unity.
  2. Press Play. The grid loads its current values from storage (defaults if first launch).
  3. Navigate with the gamepad / arrows and press the Apply button - the focused cell mutates its key.
  4. Stop and re-enter Play. The mutated values are still there.

Info

This scene wires PopupErrorHandler to ErrorHandler.OnError so any I/O failure raised through the global dispatcher spawns the ErrorPopupPrefab with the message attached.

Warning

Make sure you complete a saves module setup. (see Manual → Saves → Setup).