Class ClientSettingsBootstrap
Loads the client's configuration and applies the player's settings during boot.
public static class ClientSettingsBootstrap
- Inheritance
-
ClientSettingsBootstrap
- Inherited Members
Remarks
The problem this solves. Nothing loaded the settings file at client start-up.
Configuration.GlobalSettings was created lazily by whichever of two places asked for
it first — the launcher, or the options panel — and the options panel ships closed, so in a
client launched past the launcher neither ran. Every setting that is only ever applied by
the options panel's OnStarting was therefore not in effect until the player opened
the menu, and every setting read from the store by something else came back as a default:
keybinding overrides were skipped (LoadBindingOverrides returns early on a null
store), panel positions were not restored, and the theme was built from nothing.
Two phases, and why. The store is loaded at
UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad, which precedes every scene's
Awake — so the first panel to register already has settings to read. The settings are
applied from a hook the bootstrap system raises, immediately after it installs the
boot-time frame rate and VSync defaults. Applying them earlier than that would work exactly
once and then be overwritten by those two lines.
Input is created here too. PlayerControls used to be constructed only on
world entry, which meant the Key Bindings tab could not show a single binding until the
player was in the world, and a saved override was not loaded until then either. Creating the
asset at boot costs nothing — it is data until an action map is enabled — and makes the
bindings inspectable and editable from the login screen, which is where a player who has
just installed the game will look for them.