codeAPI Reference

s&box GamePreferences: ConVar-based user settings with attributes

calendar_today May 12, 2026 schedule ~1 min read person patrickjr verified 50

GamePreferences API Reference

GamePreferences is a static class for defining user preferences using ConVar attributes with automatic persistence.

Type Signature

CSHARP
public static class GamePreferences

Example Properties

CSHARP
[ConVar( "sb.autoswitch", ConVarFlags.UserInfo | ConVarFlags.Saved )]
public static bool AutoSwitch { get; set; } = true;

[ConVar( "sb.fastswitch", ConVarFlags.Saved )]
public static bool FastSwitch { get; set; } = false;

[ConVar( "sb.viewbob", ConVarFlags.Saved )]
[Group( "Camera" )]
public static bool ViewBobbing { get; set; } = true;

[ConVar( "sb.screenshake", ConVarFlags.Saved )]
[Range( 0.1f, 2f ), Step( 0.1f ), Group( "Camera" )]
public static float Screenshake { get; set; } = 0.3f;

Key Attributes

Notes

  • Properties with ConVarFlags.Saved are automatically persisted to disk.
  • Grouped properties appear together in the settings UI.
  • Range and Step attributes enable UI controls like sliders.
Was this helpful?