AtomSaveLoadManager

Overview

Saves and loads all UnityAtoms AtomBaseVariable assets found under Resources/{atomsResourcesFolder}. Stores each variable’s BaseValue as a string together with its runtime type, so values can be round-tripped on load. Attach to a persistent GameObject (e.g., GameController).

Disk File

  • atoms_save.json in Application.persistentDataPath.

Serialized Fields

  • string atomsResourcesFolder — subfolder inside Resources where Atom ScriptableObjects live (default: "Atoms").

Public API

  • void LoadAtomsFromResources() — (re)discovers all AtomBaseVariable assets in the configured folder.
  • void SaveAll() — serializes atom.name, runtime type and BaseValue (as string) for each atom, then writes JSON to disk.
  • void LoadAll() — reads JSON, rehydrates values by type (supports enums and primitive conversions), and assigns BaseValue for matching atoms.
  • void ResetAll() — calls Reset(true) on each discovered atom to restore its InitialValue and raise associated events.

Editor / Inspector

A custom inspector exposes buttons:

  • Save Atoms Now, Load Atoms Now, Refresh Atom List

Notes

  • Values are persisted in a type-safe manner using the value’s AssemblyQualifiedName.
  • If a value’s type can’t be resolved on load, it is skipped (with an error logged).