ZionGames Docs

Home / Zion Tools

🧰 Zion Tools

Unity Editor Asset Tools

PlayerPrefs

PlayerPrefs has no enumeration API, so the source needs to be told which keys exist. It reads from two sources, in combination: a runtime manifest key and an editor-side watch list.

Watch List window

Open Tools > Zion Games > Save Inspector > PlayerPrefs Watch List… to add or remove keys the source should watch. The same window surfaces the Restore action for any key with an auto-backup.

Runtime manifest

As a runtime alternative, your game can populate the PlayerPrefs key ZionSaveInspector.Manifest with a semicolon-separated list of keys - the source reads both. A registration helper looks like:

public static void RegisterSaveKey(string key)
{
    const string ManifestKey = "ZionSaveInspector.Manifest";
    var manifest = PlayerPrefs.GetString(ManifestKey, string.Empty);
    if (manifest.Split(';').Contains(key)) return;
    PlayerPrefs.SetString(ManifestKey,
        string.IsNullOrEmpty(manifest) ? key : manifest + ";" + key);
    PlayerPrefs.Save();
}

Any registered key whose value is JSON is parsed by the existing JsonSaveFormat just like a file.

Auto-backup

PlayerPrefsSource stashes the previous value of any key in EditorPrefs under Zion.SaveInspector.PlayerPrefs.Backup.{key} before overwriting or deleting. The Watch List window exposes a Restore button when a backup exists. Since 1.1 the same backup powers Compare > With Backup for PlayerPrefs entries.

Continue to Custom Source.