save-and-settings

Implements crash-safe save files and game settings persistence in Unity.

Updated Apr 27, 2024
One-click install
npx skills add https://github.com/IgorGribowsky/rts-sandbox --skill save-and-settings-igorgribowsky
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: save-and-settings
Source: https://github.com/IgorGribowsky/rts-sandbox/tree/main/rts-sandbox-src/.claude/skills/save-and-settings
Command: npx skills add https://github.com/IgorGribowsky/rts-sandbox --skill save-and-settings-igorgribowsky

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Game progress and player settings are often lost to corrupted save files, editor state leaks, or format changes between builds. This Skill provides rules for storing, writing, versioning, and applying save data and settings in Unity so progress survives crashes and updates. ## Core Features & Use Cases - Crash-safe file writing: Write to a temporary file, verify, then atomically replace the main file while keeping a backup, with fallback to defaults when files are missing or corrupted. - Format versioning: Embed a version field from day one and migrate older saves step by step so playtesters never lose progress after updates. - Editor-safe architecture: Avoid static manager pitfalls when Domain Reload is disabled, and apply settings (audio mixer groups, sensitivity clamping) immediately rather than only on restart. - Use Case: When adding a high-score system or a settings menu to a Unity game, use this Skill to decide where files live (Application.persistentDataPath), how to structure JSON, and how to verify persistence across full game restarts. ## Quick Start Use the save-and-settings skill to design the save file and settings storage for my Unity game.

Frequently Asked Questions about save-and-settings

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I save game progress in Unity without losing data on crash?

Write the save to a temporary file first, verify it completed, then replace the main file while keeping the previous one as a backup. On load, fall back to the backup and then to defaults if files are missing or corrupted.

Where should Unity save files be stored?

Store save files in Application.persistentDataPath, not next to the build, since protected folders on Windows and some platforms block writes there. Use the platform's path-joining APIs instead of hardcoded string paths.

How do I version a save file format in Unity?

Include a version field in the save file from the first release. When loading, migrate older versions step by step and re-save; for newer versions from a downgraded build, use the backup or defaults and inform the player.

Why does my static save manager keep stale data in the Unity editor?

Static state persists between Play sessions when Domain Reload is disabled in Enter Play Mode Settings. Keep Domain Reload enabled and add an explicit reset called at game start rather than relying on lazy initialization.

Should I use PlayerPrefs or a JSON file for game settings?

PlayerPrefs is acceptable for two or three flags, but beyond about five settings it becomes an unstructured pile of string keys. A JSON text file is human-readable, diffable, and easier to debug and migrate.

Why do my audio settings not apply until the game restarts?

Settings were saved but never applied at runtime. Apply settings through a dedicated action called both on change and on startup, using audio mixer groups rather than setting volume on each source individually.