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.
<tb:GraphicsSettingsPanel prefs-key="mygame.graphics" confirm-seconds="15" />
| 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 ConfirmSeconds 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. |
ConfirmSeconds (confirm-seconds) |
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);
Capture(camera)reads the current settings.LoadSaved(key)reads them and puts the saved values on top.Save(key),Clone(),CopyTo(target)andSameAs(other)useJsonUtility.Apply(camera)is virtual. A subclass adds its fields to the grid and applies them afterbase.Apply.- The URP options need
com.unity.render-pipelines.universal17 or later; the package definesUITOOLBOX_URPthen. Without URP, the URP categories are not there. - The URP asset values change on the asset of the current quality level. Bloom and motion blur off use a global
Volumewith priority 10000 that sets their intensity to 0, so the scene volumes stay as they are. - In the editor, the project gets its asset values, quality level, VSync and frame rate back when play mode ends (
GraphicsOptions.RestoreProject). - In the editor, the display mode and the resolution do nothing. Test them in a player build.