Save System¶
The save system stores world changes, inventory state, player transform, and world seed.
Main Scripts¶
Assets/PixitGames/BlockWorld/Scripts/SaveManager.cs
Assets/PixitGames/BlockWorld/Scripts/SaveGameData.cs
Assets/PixitGames/BlockWorld/Scripts/UI/DemoSaveMenu.cs
Save Location¶
SaveManager.SavePath uses:
Application.persistentDataPath + saveFileName
Default file name:
blockworld_save.json
Saved Data¶
| Data | Description |
|---|---|
| Seed | World seed used for regeneration |
| Player position | World position |
| Player euler angles | Rotation |
| Selected hotbar index | Active hotbar slot |
| Inventory slots | Blocks, tools, items, counts |
| Block changes | Modified block IDs by chunk/local coordinate |
New Game¶
SaveManager.NewGame():
- Clears tracked block changes.
- Randomizes or sets the seed.
- Clears inventory.
- Resets player transform.
- Generates the world.
- Saves the initial state.
Load Game¶
SaveManager.LoadGame():
- Reads JSON save data.
- Applies saved seed.
- Regenerates the world.
- Applies saved block changes.
- Loads inventory.
- Loads player transform.
Block Change Keys¶
Block changes are tracked by:
chunkX:chunkZ:x:y:z
This lets the generated world remain procedural while only storing player edits.