Game.Settings.SSRQualitySettings
Assembly: Assembly-CSharp (game)
Namespace: Game.Settings
Type: class
Base: QualitySetting
Summary:
Represents the Screen Space Reflection (SSR) quality settings used by the game's settings UI. This class maps user-configurable SSR options to the HDRP ScreenSpaceReflection volume component (UnityEngine.Rendering.HighDefinition.ScreenSpaceReflection). It registers preset profiles for Disabled, Low, Medium and High quality levels and exposes properties for enabling SSR, enabling transparent reflections, and configuring the maximum ray steps. The class also includes UI attributes used by the game's settings system.
Fields
-
private static UnityEngine.Rendering.HighDefinition.ScreenSpaceReflection m_SSRComponent
Holds a reference to the SSR Volume component (HDRP). It's created/located by CreateVolumeComponent when a VolumeProfile is provided. -
private static SSRQualitySettings highQuality
Preconfigured instance for High quality (enabled=true, enabledTransparent=true, maxRaySteps=64). Registered for Level.High. -
private static SSRQualitySettings mediumQuality
Preconfigured instance for Medium quality (enabled=true, enabledTransparent=true, maxRaySteps=32). Registered for Level.Medium. -
private static SSRQualitySettings lowQuality
Preconfigured instance for Low quality (enabled=true, enabledTransparent=false, maxRaySteps=16). Registered for Level.Low. -
private static SSRQualitySettings disabled
Preconfigured instance for Disabled (enabled=false, enabledTransparent=false). Registered for Level.Disabled.
Properties
-
public bool enabled { get; set; }
Toggle for enabling/disabling SSR. Marked with [SettingsUIHidden], so it's hidden in some UI contexts but still used by logic and Apply(). -
public bool enabledTransparent { get; set; }
Toggle for whether transparent objects contribute to SSR. Only meaningful when enabled is true. -
public int maxRaySteps { get; set; }
Controls maximum ray steps for SSR. Annotated for UI as a slider: [SettingsUISlider(min = 1f, max = 128f, step = 1f, unit = "integer")]. Values outside this range should be avoided; the code expects an integer.
Constructors
-
public SSRQualitySettings()
Default parameterless constructor. Used for creating instances (including the static preset instances). -
public SSRQualitySettings(Level quality, VolumeProfile profile)
Constructs an instance and binds it to a provided VolumeProfile. It creates/gets the ScreenSpaceReflection component from the profile (via CreateVolumeComponent) and calls SetLevel(quality, apply: false) to initialize properties from the registered presets without immediately applying them to the component. -
static SSRQualitySettings()
Static constructor registers the preset instances for Level.Disabled, Level.Low, Level.Medium and Level.High via QualitySetting.RegisterSetting.
Methods
public override void Apply()
: System.Void
Applies this setting's current property values to the HDRP ScreenSpaceReflection component (m_SSRComponent) if it exists. Uses inherited helper ApplyState to set:- m_SSRComponent.enabled <- enabled
- m_SSRComponent.enabledTransparent <- enabled && enabledTransparent
-
m_SSRComponent.m_RayMaxIterations <- maxRaySteps The method is safe if m_SSRComponent is null (no action).
-
public override bool IsOptionsDisabled()
: System.Boolean
Used by the settings UI to determine whether dependent UI options should be disabled. Returns true if the option is globally disabled via IsOptionFullyDisabled(), otherwise returns !enabled (so options are disabled when SSR is turned off). -
private static void CreateVolumeComponent(VolumeProfile profile, ref ScreenSpaceReflection component)
(inherited/used)
Called from the constructor to ensure the SSR volume component is available on the provided profile. (Implementation comes from the base QualitySetting helper methods; the class relies on that behavior.)
Usage Example
// Example: create settings bound to an HDRP VolumeProfile and apply them
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using Game.Settings;
VolumeProfile profile = /* obtain a VolumeProfile from the scene or a settings asset */;
var ssrSettings = new SSRQualitySettings(Level.High, profile);
// Update properties if needed
ssrSettings.maxRaySteps = 64;
ssrSettings.enabled = true;
ssrSettings.enabledTransparent = true;
// Apply the settings to the volume component
ssrSettings.Apply();
{{ Notes for modders
- This class depends on Unity HDRP types (ScreenSpaceReflection, VolumeProfile). Ensure your mod references UnityEngine.Rendering.HighDefinition and runs in a context where HDRP volume profiles are available.
- The UI attributes on the class and properties control how the game's settings UI displays and interacts with these options:
- [SettingsUIAdvanced] marks the section as advanced.
- [SettingsUISection("SSRQualitySettings")] sets the UI section key.
- [SettingsUIDisableByCondition(typeof(SSRQualitySettings), "IsOptionsDisabled")] disables child options when IsOptionsDisabled returns true.
- [SettingsUIHidden] hides the 'enabled' property in some UI contexts.
- [SettingsUISlider(...)] configures the slider for maxRaySteps (1–128).
- The m_SSRComponent may be null if the provided VolumeProfile does not contain a ScreenSpaceReflection component; CreateVolumeComponent will add or retrieve it when constructing with a VolumeProfile.
- Use SetLevel/Apply patterns from QualitySetting