Game.Settings.DepthOfFieldQualitySettings
Assembly: Assembly-CSharp
Namespace: Game.Settings
Type: class
Base: QualitySetting
Summary:
{{ Manages depth-of-field (DoF) quality options exposed in the settings UI. Wraps and applies values to the HDRP DepthOfField volume component (UnityEngine.Rendering.HighDefinition.DepthOfField). Provides preset registrations for Disabled, Low, Medium and High quality levels and integrates with the game's settings UI attributes (visibility, sliders, sections, and conditional disabling). }}
Fields
private static UnityEngine.Rendering.HighDefinition.DepthOfField m_DOFComponent
{{ Cached reference to the HDRP DepthOfField volume component used when applying the settings. It is created/located via CreateVolumeComponent(profile, ref m_DOFComponent) in the constructor that accepts a VolumeProfile. }}
Properties
-
public bool enabled { get; set; }
{{ Enables or disables Depth of Field. When false, the class will set the DoF mode to Off in Apply(). }} -
public int nearSampleCount { get; set; }
{{ Sample count used for near-field bokeh sampling. Exposed to UI as an integer slider (3–8). }} -
public float nearMaxRadius { get; set; }
{{ Maximum blur radius for near-field samples. Exposed to UI as a float slider (0–8, step 0.1). }} -
public int farSampleCount { get; set; }
{{ Sample count used for far-field bokeh sampling. Exposed to UI as an integer slider (3–16). }} -
public float farMaxRadius { get; set; }
{{ Maximum blur radius for far-field samples. Exposed to UI as a float slider (0–16, step 0.1). }} -
public UnityEngine.Rendering.HighDefinition.DepthOfFieldResolution resolution { get; set; }
{{ Target resolution enum for the DoF effect (e.g., Half, Quarter). }} -
public bool highQualityFiltering { get; set; }
{{ Toggles high-quality filtering for DoF. }} -
private static DepthOfFieldQualitySettings highQuality { get; }
{{ Pre-configured preset instance representing the High quality level (enabled=true, higher sample counts/radii, Half resolution, highQualityFiltering=true). Registered in the static constructor. }} -
private static DepthOfFieldQualitySettings mediumQuality { get; }
{{ Pre-configured preset instance representing the Medium quality level (balanced values). Registered in the static constructor. }} -
private static DepthOfFieldQualitySettings lowQuality { get; }
{{ Pre-configured preset instance representing the Low quality level (lower samples/radii, Quarter resolution, highQualityFiltering=false). Registered in the static constructor. }} -
private static DepthOfFieldQualitySettings disabled { get; }
{{ Pre-configured preset instance representing Disabled (enabled=false). Registered in the static constructor. }}
Constructors
-
public DepthOfFieldQualitySettings()
{{ Default parameterless constructor. Leaves properties at their CLR defaults until configured. }} -
public DepthOfFieldQualitySettings(Level quality, UnityEngine.Rendering.VolumeProfile profile)
{{ Convenience constructor that ensures the HDRP DepthOfField volume component exists (CreateVolumeComponent) and sets this instance to the named quality level via SetLevel(quality, apply: false). It does not immediately apply the changes to the volume component; call Apply() to push values. }} -
static DepthOfFieldQualitySettings()
{{ Static constructor that registers the predefined presets (disabled, low, medium, high) with the QualitySettingsystem so they are available as selectable quality levels. }}
Methods
public override void Apply()
{{ Applies the current settings to the cached HDRP DepthOfField component (m_DOFComponent) if available. Uses the inherited ApplyState helpers to set:- focusMode -> DepthOfFieldMode.Off when enabled == false
- m_NearSampleCount <- nearSampleCount
- m_NearMaxBlur <- nearMaxRadius
- m_FarSampleCount <- farSampleCount
- m_FarMaxBlur <- farMaxRadius
- m_Resolution <- resolution
-
m_HighQualityFiltering <- highQualityFiltering This method calls base.Apply() first. }}
-
public override bool IsOptionsDisabled()
{{ Returns whether the per-option UI controls should be disabled. If the setting is fully disabled via IsOptionFullyDisabled() it returns true; otherwise it returns !enabled so UI controls are disabled when Depth of Field is disabled. }}
Usage Example
// Create from a VolumeProfile and set a quality level, then apply to the volume component.
var profile = /* obtain or create a UnityEngine.Rendering.VolumeProfile used by your scene */;
var settings = new Game.Settings.DepthOfFieldQualitySettings(Level.High, profile);
// Optionally modify specific properties:
settings.highQualityFiltering = true;
settings.farMaxRadius = 12f;
// Push the settings into the HDRP DepthOfField component
settings.Apply();
{{ Notes:
- This class depends on HDRP's DepthOfField type (UnityEngine.Rendering.HighDefinition.DepthOfField). Ensure HDRP is available in the project.
- UI-related attributes on the class and properties (SettingsUIAdvanced, SettingsUISection, SettingsUISlider, SettingsUIHidden, SettingsUIDisableByCondition) control how the in-game settings UI displays and binds these values.
- The ApplyState method used here is inherited from QualitySetting