主题
Client Settings
Use this skill when a task adds or changes client-side game settings, project settings UI, local graphics/audio options, or lightweight local preferences.
Human-facing doc: docs/systems/ClientSettingsSystem.md.
Fit Check
| Goal | Use |
|---|---|
| Graphics preset, FPS cap, render resolution, scene/particle quality, HDR, anti-aliasing | ClientSettings.Graphics |
| Music/effects/voice/microphone volume or enabled state | ClientSettings.Audio |
| Local project preference such as damage numbers, camera sensitivity, local HUD choice | ClientSettings.Preferences |
| Cross-device save, currency, inventory, progression, purchase state | CloudData or server-side system, not this skill |
| Runtime SCE weather, fog, lighting, LightGroup presets | sce-scene-environment |
Boundaries
- Put usage under
#if CLIENT. - Validate settings in a separate client process, including a connected client launched by the Headless Editor. PIE does not fully support graphics/audio/preferences persistence or readback; both Game and Device preference scopes are affected. Do not diagnose a standalone-client failure from PIE results alone.
- PIE calls can still change process-wide editor audio, frame rate or anti-aliasing, without guaranteed restoration after stopping. Updated editor binaries warn once per PIE game session on first settings read/write; the warning does not block calls or change existing behavior.
- These settings are local client state. They do not sync to the server and are not gameplay authority.
- There are no change events. Read current values when opening the UI; write values when the user changes or confirms them.
- Do not poll or rewrite settings every frame.
- Do not store secrets, large JSON blobs, progression, payments, inventory, or cross-device data in
Preferences. - Built-in graphics/audio settings share the platform settings store; custom
Preferencesare project-owned and will not appear automatically in the platform settings panel.
Entry Pattern
csharp
#if CLIENT
using GameCore.ClientSettings;
ClientSettings.Graphics.Preset = GraphicsPreset.Balanced;
ClientSettings.Audio.Music.Volume = 70;
ClientSettings.Preferences.SetBool("show_damage_numbers", true);
#endifGraphics Pattern
Use presets for broad choices, and individual properties for an advanced settings page.
csharp
#if CLIENT
using GameCore.ClientSettings;
ClientSettings.Graphics.Preset = GraphicsPreset.High;
ClientSettings.Graphics.RenderResolution = RenderResolutionLevel.High;
ClientSettings.Graphics.SceneQuality = SceneQuality.Ultra;
ClientSettings.Graphics.ParticleQuality = ParticleQuality.High;
ClientSettings.Graphics.HdrEnabled = true;
ClientSettings.Graphics.AntiAliasingEnabled = true;
#endifFrame-rate cap:
csharp
#if CLIENT
ClientSettings.Graphics.MaxFrameRate = 120;
int? cap = ClientSettings.Graphics.MaxFrameRate;
if (cap is null)
{
// No explicit FPS cap.
}
ClientSettings.Graphics.ClearMaxFrameRate();
// Equivalent: ClientSettings.Graphics.MaxFrameRate = null;
#endifRules:
MaxFrameRateaccepts positive integers ornull.- Use
ClearMaxFrameRate()orMaxFrameRate = nullto remove the explicit cap. - Do not ask users to pass
0as a public API pattern;0is only the platform storage/runtime sentinel. - Platform settings UI may only expose fixed FPS choices. If it later saves the same setting, it may clamp arbitrary caps to a supported UI option.
- Individual graphics property writes may mark the graphics preset as
GraphicsPreset.Custom.
Audio Pattern
csharp
#if CLIENT
using GameCore.ClientSettings;
ClientSettings.Audio.Music.Volume = 60;
ClientSettings.Audio.Effects.Volume = 85;
ClientSettings.Audio.Voice.Enabled = false;
var musicVolume = ClientSettings.Audio.Music.Volume;
var effectsEnabled = ClientSettings.Audio.Effects.Enabled;
ClientSettings.Audio[AudioChannel.Microphone].Enabled = true;
#endifRules:
- Volume is
0..100. Enabledis the mute/unmute control; do not manually rewrite volume to represent enabled state.- Use
Musicfor background/cutscene music,Effectsfor UI, combat, movement, foley, doodad, alert, and normal effect sounds, andVoicefor in-game dialogue/voice plus voice chat playback. AudioChannelis a player-facing settings group, not the same concept asGameDataSound.Category.- Do not describe
AudioChannelandGameDataSound.Categoryas multiplicative layers.AudioChannelwrites batches of native sound type gains;GameDataSound.Categorydecides which sound type gain an ActorSound uses.
Preferences Pattern
csharp
#if CLIENT
using GameCore.ClientSettings;
ClientSettings.Preferences.SetBool("show_damage_numbers", true);
ClientSettings.Preferences.SetFloat("camera_sensitivity", 0.75f);
ClientSettings.Preferences.SetString("hud_layout", "compact");
var showDamageNumbers = ClientSettings.Preferences.GetBool("show_damage_numbers", defaultValue: true);
var sensitivity = ClientSettings.Preferences.GetFloat("camera_sensitivity", defaultValue: 0.5f);
var hudLayout = ClientSettings.Preferences.GetString("hud_layout", defaultValue: "default");
#endifUse the default ClientSettingScope.Game for project-specific settings. Use ClientSettingScope.Device only for deliberate device-wide preferences:
csharp
#if CLIENT
ClientSettings.Preferences.SetBool(
"developer_overlay_enabled",
true,
ClientSettingScope.Device);
#endifKey rules:
- Keep keys stable and readable.
- Prefer simple booleans, floats, and short strings.
- Use project-specific names for shared/device keys to avoid collisions.
UI Implementation Checklist
- Read current settings when the settings panel opens.
- Bind sliders/toggles/segmented controls to local UI state.
- Apply settings on user action or confirmation.
- For FPS, include a "no cap" / "unlimited" choice that calls
ClearMaxFrameRate(). - Re-read settings if the panel is reopened after the platform settings UI may have changed values.
Validation
powershell
dotnet build src\GameEntry.csproj -c Client-DebugThen run the client and verify:
- Initial UI values match current
ClientSettingsproperties. - Changed graphics/audio settings apply in the current client.
- Settings survive leaving and re-entering the game.
- Arbitrary FPS caps and
ClearMaxFrameRate()behave as expected on the target runtime.
Related
docs/systems/ClientSettingsSystem.mddocs/ai/skills/ui-layout-api/SKILL.mddocs/systems/CloudDataSystem.mddocs/guides/ClientOnlyDebug.mddocs/ai/skills/sce-preview-verify/SKILL.md