Game.Settings.DynamicResolutionScaleSettings
Assembly:
Assembly-CSharp (game code)
{{ This class is part of the game's runtime assembly (commonly Assembly-CSharp.dll for Unity projects). It's used by the game's settings system for dynamic resolution configuration. }}
Namespace:
Game.Settings
Type:
class
Base:
QualitySetting
Summary:
Represents the dynamic resolution settings exposed in the game's graphics/settings UI. Controls whether dynamic resolution is enabled, whether it is adaptive, the minimum resolution scale, and the upscaling filter used. This class registers preset ("mock") quality entries (Constant, Automatic, Disabled) and applies its values to the AdaptiveDynamicResolutionScale singleton when Apply() is called. Attributes on the class and members control how it appears and behaves in the settings UI (e.g., hiding, sectioning, disabling by condition).
{{ Notes:
- This class is used by Cities: Skylines 2 to configure runtime dynamic resolution behavior.
- It relies on AdaptiveDynamicResolutionScale.instance to actually apply rendering changes.
- The minScale property is presented in the UI as a slider between 50% and 100% (stored as 0.5–1.0).
}}
Fields
private static UnityEngine.Camera m_Camera
{{ Static cached reference used when applying the settings to give the AdaptiveDynamicResolutionScale the gameplay camera. The camera is obtained via TryGetGameplayCamera when Apply() runs. }}
Properties
-
public bool enabled { get; set; }
{{ Toggle for turning dynamic resolution on/off. Marked with [SettingsUIHidden] in the source so it may be hidden in certain UI contexts. When false the option is considered disabled. }} -
public bool isAdaptive { get; set; }
{{ When true the resolution controller adapts scale dynamically according to performance targets; when false the controller uses a constant scale (minScale). }} -
public AdaptiveDynamicResolutionScale.DynResUpscaleFilter upscaleFilter { get; set; }
{{ Selects the upscaling filter used when dynamic resolution upscales the render target. The enum comes from AdaptiveDynamicResolutionScale. }} -
[SettingsUISlider(min = 50f, max = 100f, step = 1f, unit = "percentageSingleFraction", scalarMultiplier = 100f)] public float minScale { get; set; }
{{ Minimum resolution scale (stored as fraction 0.5–1.0). The SettingsUISlider attribute displays this as a 50–100% slider in the UI by applying the scalarMultiplier. }} -
private static DynamicResolutionScaleSettings constantQuality { get; }
{{ Private static preset property returning the "Constant" preset: enabled=true, isAdaptive=false, EdgeAdaptiveScaling upscale filter, minScale=0.5. Registered as Level.Low. }} -
private static DynamicResolutionScaleSettings automaticQuality { get; }
{{ Private static preset property returning the "Automatic" preset: enabled=true, isAdaptive=true, EdgeAdaptiveScaling upscale filter, minScale=0.5. Registered as Level.Medium. }} -
private static DynamicResolutionScaleSettings disabledQuality { get; }
{{ Private static preset property returning the "Disabled" preset: enabled=false. Registered as Level.High. }}
Constructors
-
public DynamicResolutionScaleSettings()
{{ Default constructor. Initializes an empty instance (properties left to default values). Typical use is letting the settings system populate values or creating a custom settings instance to Apply(). }} -
static DynamicResolutionScaleSettings()
{{ Static constructor registers the preset/mock names and the preset instances with QualitySetting: - Level.Low → "Constant" (constantQuality)
- Level.Medium → "Automatic" (automaticQuality)
-
Level.High → "Disabled" (disabledQuality) This ensures the UI shows the named presets and the quality selector maps to these presets. }}
-
public DynamicResolutionScaleSettings(Level quality)
{{ Convenience constructor that sets the instance to the provided preset level by calling SetLevel(quality, apply: false). This creates a settings object pre-populated from the registered settings for that quality level. }}
Methods
-
public override void Apply()
{{ Applies the current settings to the runtime AdaptiveDynamicResolutionScale system. Calls base.Apply() (to persist or hook into the overall settings pipeline), attempts to obtain the gameplay camera via TryGetGameplayCamera(ref m_Camera), and if successful calls AdaptiveDynamicResolutionScale.instance.SetParams(enabled, isAdaptive, minScale, upscaleFilter, m_Camera). This is the method that makes the graphics changes take effect at runtime. }} -
public override bool IsOptionsDisabled()
{{ UI helper used by the SettingsUIDisableByCondition attribute: returns whether the option group should be disabled. Logic: if enabled is true, it defers to IsOptionFullyDisabled(); otherwise it returns true (disabled when enabled == false). }} -
public override bool IsOptionFullyDisabled()
{{ Further UI enabling logic: returns true if the option is fully disabled by other conditions. Implementation: if base.IsOptionFullyDisabled() returns false and DLSS is not active, then it returns whether FSR2 is active (SharedSettings.instance.graphics.isFsr2Active). Otherwise it returns true. In short, the option is treated as fully disabled in some interactions with DLSS/FSR2 state. }}
Usage Example
// Apply a built-in preset (e.g., Constant preset registered at Level.Low)
var preset = new DynamicResolutionScaleSettings(Level.Low);
preset.Apply();
// Create and apply a custom setting instance
var custom = new DynamicResolutionScaleSettings
{
enabled = true,
isAdaptive = false,
minScale = 0.75f, // 75%
upscaleFilter = AdaptiveDynamicResolutionScale.DynResUpscaleFilter.EdgeAdaptiveScaling
};
custom.Apply();
{{ Additional tips: - The class is integrated into the game's settings UI through attributes such as SettingsUIAdvanced and SettingsUISection. Use the provided presets (Constant/Automatic/Disabled) when exposing quality levels in your mod. - Changing settings at runtime should be done on the main thread; Apply() will internally try to find the gameplay camera to pass to the adaptive resolution controller. - Be mindful of interactions with DLSS/FSR2: IsOptionFullyDisabled reflects those interactions to avoid conflicting runtime upscalers. }}