Extending and API
Everything is in the RomanoAssets.SettingsMenu namespaces. The kit's public API won't break in 1.x updates (an automated test checks every public type, member, serialized field, script GUID, menu item and setting id against the released version).
Read a setting #
using RomanoAssets.SettingsMenu;
var settings = SettingsRuntime.Current; // created by the front end or a Settings Bootstrap
float shake = settings.GetFloat("gameplay.camera-shake", 1f);
bool hints = settings.GetBool("gameplay.hints");
string difficulty = settings.GetValue("gameplay.difficulty");
Ids are listed in the Settings reference.
React when settings change #
// Connect tier: called now and after every Apply that changes it.
SettingsRuntime.Current.Connect("gameplay.field-of-view", v => cam.fieldOfView = float.Parse(v, System.Globalization.CultureInfo.InvariantCulture));
// Any tier: an event per applied setting.
SettingsRuntime.Current.ValueApplied += d => Debug.Log($"{d.Id} is now {SettingsRuntime.Current.GetValue(d.Id)}");
No code: add a Setting Event Binder component (UnityEvents for float, int, bool and string values).
A connector component #
public sealed class LightIntensityTarget : SettingConnector
{
[SerializeField] Light target;
protected override void OnValue(string value) =>
target.intensity = float.Parse(value, System.Globalization.CultureInfo.InvariantCulture);
}
Your own Auto setting #
Derive a definition (for example from FloatSettingDefinition) and an applier, and register the applier once:
public sealed class GammaApplier : SettingApplier
{
public override bool Handles(SettingDefinition d) => d is GammaSettingDefinition;
public override void Apply(SettingsController c, IReadOnlyList<SettingDefinition> changed)
{
foreach (var d in changed) MyPostStack.SetGamma(c.GetFloat(d.Id, 1f));
}
}
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
static void Register() => SettingsAppliers.Register(() => new GammaApplier());
Change settings from code #
var c = SettingsRuntime.Current;
c.SetPendingFloat("audio.music-volume", 0.5f);
c.Apply(); // or c.Cancel()
The menu #
var menu = MenuRoot.Instance;
menu.SetHasSave(true); // shows Continue
menu.EnterGameplay(); // hide menus; Esc / Start pauses
menu.ShowFrontEnd(); // back to the main menu
menu.Pause(); menu.Resume();
menu.SetTheme(myTheme);
menu.LoadScene("Level1", MenuMode.Gameplay); // with the loading screen
Accessibility, subtitles, languages #
SubtitleDisplay.Show("Over here!", 3f, "Mara");
float shake = AccessibilityState.CameraShakeScale; // 0 with Reduce Motion
bool reduced = AccessibilityState.ReducedMotion;
string label = MenuLocalization.Get("mygame.hud.ammo", "Ammo");
Optional integrations #
URP, the Input System, Post Processing v2, Cinemachine and Unity's Localization package are detected with assembly versionDefines: their code compiles only when the package is installed, and nothing is required.