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— viaGetSetting/SetSettingbool— viaGetSettingBool/SetSettingBoolorAutoSettingglm::vec3— viaGetSettingVec3/SetSettingVec3orAutoSettingchar buffer[]— viaAutoSetting
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