Skip to content

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():

  1. Clears tracked block changes.
  2. Randomizes or sets the seed.
  3. Clears inventory.
  4. Resets player transform.
  5. Generates the world.
  6. Saves the initial state.

Load Game

SaveManager.LoadGame():

  1. Reads JSON save data.
  2. Applies saved seed.
  3. Regenerates the world.
  4. Applies saved block changes.
  5. Loads inventory.
  6. 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.