Skip to content

Save, settings and difficulty

How saving works

The game writes everything to a single encrypted file, save.dat, in Application.persistentDataPath: the checkpoint, profile (settings, points, unlocks), best medals and level state. It saves at checkpoints, at the end of a level, when settings change, and when buying or equipping in the shop. Progress after the last checkpoint is lost if the player quits.

On Windows the file is at %USERPROFILE%\AppData\LocalLow\<Company>\<Product>\save.dat. Corrupted or other-version files are set aside as save.dat.invalid-<date>.

Before you ship

Change Company Name and Product Name in Project Settings > Player. They define your game's save folder.

To delete the save during development: Tools > AiasTech > Cheats > Save > Delete Save.

Encryption key: edit KeyPassphrase in Scripts/SaveSystem/Encryption/AesEncryptionProvider.cs. Old saves stop opening and a new one is created. Encryption detects corruption and deters casual editing, but it is not security: the key ships inside the executable.

WebGL saves are plain JSON

On WebGL, save.dat is written unencrypted. Key derivation (PBKDF2, 100,000 iterations) runs on a single WebAssembly thread and froze the page for seconds, and browser storage (IndexedDB) is editable via DevTools anyway. Older encrypted saves still open and become JSON on the next write. Other platforms stay encrypted.

Save new data

  1. Add the property, with a safe default, to the right save module, and handle nulls in its Normalize().
  2. Capture and restore the value in your system.
  3. Call SaveManager.Instance.RequestSave() (debounced) or Save() (immediate). Changing a module doesn't schedule a write.

Versioning

Adding properties is compatible with existing saves. Renaming, removing or changing a type requires bumping SaveFileData.CurrentVersion, and old saves are discarded (no migration).

For integer preferences, use the profile helpers:

using AiasTech.SaveSystem;

int value = SaveManager.GetProfileInt(SaveSystemKeys.SettingsShowFPS, 0);
SaveManager.SetProfileInt(SaveSystemKeys.SettingsShowFPS, 1);
SaveManager.ProfileChanged += key => { /* react to the change */ };

To save a scene object, see Level logic. There is one save slot, with no cloud save or multiple profiles. IDs and scene names can't contain , or ;. For internals, see Assets/DungeonCrawler/Scripts/SaveSystem/ARCHITECTURE.md.

Player settings

The settings screen (main menu) has the tabs Game (language, difficulty, HUD portrait), Graphics, Keybind, Audio and HUD. Defaults: middle quality, the highest resolution of at least 1920×1080 in the monitor's aspect ratio, and FPS capped at 60. Resolution is applied only in builds, not in the editor.

Global values

Resources/GameSettings.asset holds design values such as points per medal (None/Bronze/Silver/Gold/Platinum: 0 / 5 / 10 / 18 / 25) and ammo start/max. Don't rename or move it, don't store player preferences in it, and don't change it at runtime.

Difficulty

Difficulty levels are in Resources/Difficulty.asset (edit it; don't create another). Each has a Key (in the Settings table) and multipliers for enemies, bosses, minions, area damage, LootDropChance and points.

Level Damage Health Boss dmg/health Area Drop Points
Baby 0.5 0.75 0.5 / 0.75 0.5 1 0.5
Normal (default) 1 1 1 / 1 1 0.85 1
Hard 1.25 1.15 1.1 / 1.1 1.25 0.7 1.25
Nightmare 1.5 1.5 1.4 / 1.4 1.5 0.55 1.5
Hell 2 2 2 / 2 2 0.4 2

Minions stay at 1 on every level. Difficulty does not change the player or level content.

To add a level, edit the Levels list and create its Key in the Settings table in both languages; the selector updates automatically.

Warning

The save stores the position in the list. Reordering changes the difficulty of existing players.

A new field on DifficultyLevel does nothing by itself: your system must read DifficultyManager.Instance.GetCurrentDifficulty() and apply it.