codeCode Mode

This approach is designed for experienced developers who want full programmatic control over saving and loading.

⚠️ Usually, you don’t need this, adding Saveable components handles everything for you automatically. Use this method only if you want to bypass components entirely, or if you need custom save logic.

Below is a simple example showing how to save data directly in code, without attaching any components to your GameObjects.

SaveManager.Save()

Saves a value to memory.

public static void Save<T>(string key, T value, PersistenceScope scope)

Parameters:

  • key: Unique identifier (for example, "playerHealth")

  • value: Any serializable value

  • scope: PersistenceScope.Global or PersistenceScope.Scene . If you´re unsure what PersistenceScope means, please refer to Persistence Scope Core Concepts.

Examples:

SaveManager.Save("health", 100, PersistenceScope.Global);
SaveManager.Save("position", transform.position, PersistenceScope.Scene);
SaveManager.Save("inventory", myInventoryList, PersistenceScope.Global);

⚠️⚠️ IMPORTANT !! ⚠️⚠️

triangle-exclamation

OmniSave uses a two-phase save:

  1. Save() → Writes to RAM (temporary, it´s not really saved anywhere persistent)

  2. SaveAll() → Writes to disk (persistent)

SaveManager.Load()

Loads a value from memory/disk.

Returns: Loaded value or defaultValue if not found.

Examples:

SaveManager.Has()

Checks if a key exists.

Example:

SaveManager.Delete()

Removes a key.

Example:

API Method List

Refer to Full SaveManager API

Common Patterns

Pattern 1: Player Stats

Pattern 2: Checkpoint System

Pattern 3: Progression System

Pattern 4: Custom Data Structures

Combining Code-First + Saveable Component

They work seamlessly together in the same slot:

Last updated