Game.Settings.CloudsQualitySettings
Assembly:
Namespace: Game.Settings
Type: class
Base: QualitySetting
Summary:
CloudsQualitySettings controls cloud-related quality options for Cities: Skylines 2 using HDRP Volume components. It provides presets (Disabled, Low, Medium, High) and exposes boolean options for toggling volumetric clouds, distance (layer) clouds, and their shadows. The class reads and applies these settings by creating/using Volume components from a provided VolumeProfile (VolumetricClouds, VisualEnvironment, CloudLayer). Several editor/UI attributes are applied to integrate the setting into the game's settings UI ([SettingsUIAdvanced], [SettingsUISection], [SettingsUIDisableByCondition]).
Fields
-
private static VolumetricClouds m_VolumetricClouds
Holds a reference to the HDRP VolumetricClouds volume component used to control volumetric-cloud-specific parameters (enable, shadows, etc.). This is populated via CreateVolumeComponent when constructed with a VolumeProfile. -
private static VisualEnvironment m_VisualEnvironment
Reference to the HDRP VisualEnvironment volume component. Used to set cloud type (used here to enable/disable distance clouds by setting cloudType). -
private static CloudLayer m_CloudLayer
Reference to the HDRP CloudLayer volume component. Used to control layer-specific settings such as cast shadows for distance clouds. -
private static CloudsQualitySettings highQuality
Private static property returning a CloudsQualitySettings instance configured for High quality (volumetric + distance clouds enabled, both shadows enabled). -
private static CloudsQualitySettings mediumQuality
Private static property returning a CloudsQualitySettings instance configured for Medium quality (volumetric + distance enabled, volumetric shadows off, distance shadows on). -
private static CloudsQualitySettings lowQuality
Private static property returning a CloudsQualitySettings instance configured for Low quality (volumetric clouds off, distance clouds enabled, shadows off). -
private static CloudsQualitySettings disabled
Private static property returning a CloudsQualitySettings instance configured for Disabled quality (no clouds).
Properties
-
public bool volumetricCloudsEnabled { get; set; }
Controls whether HDRP volumetric clouds are enabled when Apply() is called. -
public bool distanceCloudsEnabled { get; set; }
Controls whether distance/layer clouds (cloud layers) are enabled. Applied by adjusting VisualEnvironment.cloudType. -
public bool volumetricCloudsShadows { get; set; }
Controls whether volumetric cloud shadows are enabled. -
public bool distanceCloudsShadows { get; set; }
Controls whether distance cloud layer shadows are enabled (CloudLayer.layerA.castShadows).
Constructors
-
public CloudsQualitySettings()
Default parameterless constructor. -
public CloudsQualitySettings(Level quality, VolumeProfile profile)
Constructs the setting using a given VolumeProfile. This constructor: - Calls CreateVolumeComponent(profile, ref m_VolumetricClouds) and similarly for m_VisualEnvironment and m_CloudLayer to cache HDRP volume components.
-
Calls SetLevel(quality, apply: false) to initialize the instance values according to the given quality preset without immediately applying them to the profile.
-
static CloudsQualitySettings()
(static constructor)
Registers the preset CloudQuality settings with the QualitySettingbase class: - Level.Disabled → disabled
- Level.Low → lowQuality
- Level.Medium → mediumQuality
- Level.High → highQuality
Methods
public override void Apply()
: System.Void
Applies the current CloudsQualitySettings values to the cached HDRP Volume components (if present). Specifically:- Sets m_VolumetricClouds.enable to volumetricCloudsEnabled.
- Sets m_VolumetricClouds.shadows to volumetricCloudsShadows.
- Sets m_VisualEnvironment.cloudType to 1 when distanceCloudsEnabled is true, otherwise 0.
- Sets m_CloudLayer.layerA.castShadows to distanceCloudsShadows. The call guards against null component references.
Usage Example
// Assume 'profile' is an existing VolumeProfile from the scene or a created profile.
// Create a CloudsQualitySettings instance from a given quality level and profile:
var cloudsSetting = new CloudsQualitySettings(Level.High, profile);
// Optionally modify individual flags:
cloudsSetting.volumetricCloudsEnabled = true;
cloudsSetting.volumetricCloudsShadows = false;
// Apply the settings to the profile's Volume components (if present):
cloudsSetting.Apply();
// You can also get preset instances via the QualitySetting registration system:
// e.g., QualitySetting<CloudsQualitySettings>.Get(Level.Low) (depending on the base API)
Notes:
- This class relies on HDRP types (VolumetricClouds, VisualEnvironment, CloudLayer) from UnityEngine.Rendering.HighDefinition; ensure HDRP is available.
- The CreateVolumeComponent and SetLevel methods are provided by the QualitySetting