Per-Script Settings

Each ScriptComponent owns serialized key/value strings (ctx.script->settings). Use them to persist state with the scene.

Direct Settings

1 400">void TickUpdate(400">ScriptContext& ctx, 400">float) {
2 400">if (!ctx.script) 400">return;
3 ctx.SetSetting("mode", "hard");
4 ctx.MarkDirty();
5 }

AutoSetting (Recommended)

AutoSetting binds a variable to a key and loads/saves automatically when you call SaveAutoSettings().

1 400">extern "C" 400">void Script_OnInspector(400">ScriptContext& ctx) {
2 400">static 400">bool enabled = 400">false;
3 ctx.AutoSetting("enabled", enabled);
4 400">ImGui::Checkbox("Enabled", &enabled);
5 ctx.SaveAutoSettings();
6 }

Supported Types

  • std::string — via GetSetting/SetSetting
  • bool — via GetSettingBool/SetSettingBool or AutoSetting
  • glm::vec3 — via GetSettingVec3/SetSettingVec3 or AutoSetting
  • char buffer[] — via AutoSetting

Key Points

  • Settings are loaded automatically when the script starts
  • Settings are saved only when changed
  • Settings are stored per object / per script instance
  • Call ctx.MarkDirty() after mutating settings you want to persist