UI Toolbox logoUI Toolbox
Support

GraphicsSettingsPanel and GraphicsOptions

A GraphicsSettingsPanel is a graphics settings screen that changes the real settings of the game. It is a PropertyGrid of GraphicsOptions with Defaults, Revert and Apply buttons.

The display settings of a graphics panel, with Defaults, Revert and Apply buttonsThe display settings of a graphics panel, with Defaults, Revert and Apply buttons

<tb:GraphicsSettingsPanel
    prefs-key="mygame.graphics"
    confirm-duration="15000" />
Category Options
Display Display mode (FullScreenMode), resolution (a dropdown of Screen.resolutions), VSync, limit frame rate and maximum frame rate, horizontal field of view.
Quality The quality level (a dropdown of QualitySettings.names). With URP: render scale, upscaling filter, anti-aliasing and its quality, MSAA, HDR.
Shadows (URP) Shadows on the camera, shadow distance, shadow cascades.
Effects (URP) Post-processing, bloom, motion blur.
Member Description
Editing The options that the grid edits. Set a subclass of GraphicsOptions to add the options of a game.
Applied The options of the last Apply, or the saved options.
IsDirty True when Editing differs from Applied. Apply and Revert are enabled only then.
ApplyAsync() Sets Editing on the game and saves it. A display mode or resolution change asks "Keep these display settings?" and goes back after ConfirmDuration without an answer. True when the edits stay.
Revert(), Defaults() Sets Editing to Applied, or to the settings when the game started.
PrefsKey (prefs-key) The PlayerPrefs key (tb.graphics). The panel loads the saved options on the first attach. Empty: Apply does not save.
ShowButtons (show-buttons) False hides the buttons, for a larger settings screen with its own buttons that call the methods.
ConfirmDuration (confirm-duration) The seconds of the keep box (15). 0: Apply does not ask.
Camera The camera of the field of view and the URP camera options. Null: Camera.main.
Grid The PropertyGrid.

GraphicsOptions works without the panel:

// At the start of the game: set the saved options
GraphicsOptions.LoadSaved("mygame.graphics").Apply(Camera.main);

The fields of GraphicsOptions, which code reads and sets by name:

Field Default Description
DisplayMode FullScreenWindow The FullScreenMode: full screen or a window.
Resolution "" The size and the refresh rate, as the text of one of Screen.resolutions. A text that matches none keeps the current resolution.
VSync true Waits for the display refresh: no tearing, some input delay.
LimitFrameRate, MaxFrameRate false, 60 Caps the frame rate at MaxFrameRate (30 to 240) while VSync is off.
FieldOfView 90 The horizontal view angle of the camera in degrees (60 to 120).
Quality 0 The index of the quality level in QualitySettings.names.
RenderScale 100 URP. The percent of the screen resolution to render at (50 to 200).
Upscaling Auto URP. The filter that scales a lower render scale up.
AntiAliasing, AntiAliasingQuality None, High URP. The post-process anti-aliasing of the camera and its quality.
Msaa Off URP. The MsaaSamples of the pipeline: Off, X2, X4 or X8.
Hdr true URP. Renders bright light with more range.
Shadows, ShadowDistance, ShadowCascades true, 50, 4 URP. The lights cast shadows, up to a distance in meters (10 to 300), with 1 to 4 cascades.
PostProcessing, Bloom, MotionBlur true URP. The screen effects of the camera, and the bloom and motion blur of the scene volumes.

DisplayDiffers(other) is true when the display mode or the resolution differ: the change after which the panel asks to keep the settings.

The GraphicsSettingsPanelDemo scene shows the panel with no setup over a small 3D arena, the question after a display change and a subclass with an option of its own, what it saves and loads, Apply, Revert and the events, the keys and the gamepad, and the panel in a glass and a bamboo look.