Game.Settings.ShadowsQualitySettings
Assembly: Assembly-CSharp (game)
Namespace: Game.Settings
Type: class
Base: QualitySetting
Summary:
Manages shadow-related quality options for the game (Cities: Skylines 2). This class wraps HDRP shadow settings (HDShadowSettings) and sun light data (HDAdditionalLightData), exposes per-quality presets (Disabled/Low/Medium/High), registers those presets with the QualitySetting system, and applies the chosen settings to the active volume components and terrain surfaces. It also integrates with the game's settings UI via attributes (SettingsUIAdvanced, SettingsUISection, SettingsUIDisableByCondition). The class depends on HD Render Pipeline types and the QualitySetting base that provides helper methods such as CreateVolumeComponent and TryGetSunLightData.
Fields
-
private static UnityEngine.Rendering.HighDefinition.HDShadowSettings m_CascadeShadows
Reference to the HDShadowSettings volume component used to control cascade shadow parameters in HDRP. Obtained via CreateVolumeComponent when a VolumeProfile is provided. -
private static UnityEngine.Rendering.HighDefinition.HDAdditionalLightData m_SunLightData
Cached reference to the sun's HDAdditionalLightData. Used to enable/disable shadows for the directional light (sun). Populated on first Apply() by TryGetSunLightData. -
private static ShadowsQualitySettings highQuality
Private static expression-bodied member returning a ShadowsQualitySettings instance configured for High quality: enabled=true, directionalShadowResolution=2048, terrainCastShadows=true, shadowCullingThresholdHeight=1f, shadowCullingThresholdVolume=1f. -
private static ShadowsQualitySettings mediumQuality
Private static expression-bodied member returning a ShadowsQualitySettings instance configured for Medium quality: enabled=true, directionalShadowResolution=1024, terrainCastShadows=true, shadowCullingThresholdHeight=1.5f, shadowCullingThresholdVolume=1.5f. -
private static ShadowsQualitySettings lowQuality
Private static expression-bodied member returning a ShadowsQualitySettings instance configured for Low quality: enabled=true, directionalShadowResolution=512, terrainCastShadows=false, shadowCullingThresholdHeight=2f, shadowCullingThresholdVolume=2f. -
private static ShadowsQualitySettings disabled
Private static expression-bodied member returning a ShadowsQualitySettings instance for Disabled quality: enabled=false. -
static ShadowsQualitySettings()
(static constructor)
Registers the four preset instances with the QualitySettingsystem: RegisterSetting(Level.Disabled, disabled); RegisterSetting(Level.Low, lowQuality); RegisterSetting(Level.Medium, mediumQuality); RegisterSetting(Level.High, highQuality);
Properties
-
public bool enabled { get; set; }
Controls whether directional shadows are enabled. Also used to enable/disable the cascade shadows volume component and to disable options in the UI when shadows are turned off. -
public int directionalShadowResolution { get; set; }
Resolution used for directional (sun) shadow maps for the configured quality level. -
public bool terrainCastShadows { get; set; }
Whether terrain surfaces will cast shadows at this quality level. Applied to all TerrainSurface.instances in Apply(). -
public float shadowCullingThresholdHeight { get; set; }
Height threshold used for shadow culling (higher values generally cull more small/high objects). -
public float shadowCullingThresholdVolume { get; set; }
Volume threshold used for shadow culling (higher values generally cull more small-volume objects).
(Note: The private static preset members described above are expression-bodied properties returning preconfigured ShadowsQualitySettings instances.)
Constructors
-
public ShadowsQualitySettings()
Default parameterless constructor. Useful when constructing an instance to be configured manually or by the QualitySetting system. -
public ShadowsQualitySettings(Level quality, VolumeProfile profile)
Constructs a ShadowsQualitySettings from a Level and a VolumeProfile. This does two things: - Calls CreateVolumeComponent(profile, ref m_CascadeShadows) (inherited from QualitySetting) to locate the HDShadowSettings component in the provided VolumeProfile and cache it.
- Calls SetLevel(quality, apply: false) to set the property values from the registered preset for the given quality level without immediately applying them.
Methods
public override void Apply()
Applies the current settings to the game:- Ensures m_SunLightData is populated by calling TryGetSunLightData(ref m_SunLightData) if null (inherited helper).
- Calls m_SunLightData.EnableShadows(enabled) when sun data is available to enable/disable directional shadows on the sun light.
- Sets m_CascadeShadows.active = enabled to enable/disable the cascade shadow volume component if it was found.
- Iterates TerrainSurface.instances and sets each instance.castShadows = terrainCastShadows to apply terrain shadow casting behavior.
This method calls base.Apply() first (so the base class can perform its work).
public override bool IsOptionsDisabled()
Determines whether UI options bound to this settings group should be disabled. Returns true if the setting is "fully disabled" (IsOptionFullyDisabled() from base), otherwise it returns !enabled — i.e., individual options are disabled when shadows are turned off.
Usage Example
// Example: create settings from a volume profile and apply the High quality preset
var profile = /* obtain VolumeProfile from your scene/volume */;
var settings = new ShadowsQualitySettings(Level.High, profile);
// Optionally tweak a value
settings.directionalShadowResolution = 2048;
// Apply changes to the scene (enables cascade component, toggles sun shadows, updates terrain)
settings.Apply();
Additional notes:
- This class relies on Unity's High Definition Render Pipeline (UnityEngine.Rendering.HighDefinition) types (HDShadowSettings, HDAdditionalLightData) and on a TerrainSurface type (TerrainSurface.instances) present in the game code.
- Preset registration happens in the static constructor; the QualitySetting