Game.Settings.LevelOfDetailQualitySettings
Assembly: Assembly-CSharp
Namespace: Game.Settings
Type: class
Base: QualitySetting
Summary:
LevelOfDetailQualitySettings is a quality-setting class used to configure level-of-detail (LOD) and related rendering budgets for Cities: Skylines 2. It exposes UI attributes for in-game settings (sliders, units, and enable/disable conditions) and, when applied, writes values into the game's RenderingSystem and BatchMeshSystem. The class also provides preset configurations (VeryLow, Low, Medium, High) which are registered with the QualitySetting<> registry in the static constructor.
Fields
private static LevelOfDetailQualitySettings highQuality
Preset instance for the High quality level. Values:- levelOfDetail = 0.7
- lodCrossFade = true
- maxLightCount = 8192
- meshMemoryBudget = 2048 (MB)
-
strictMeshMemory = false
-
private static LevelOfDetailQualitySettings mediumQuality
Preset instance for the Medium quality level. Values: - levelOfDetail = 0.5
- lodCrossFade = true
- maxLightCount = 4096
- meshMemoryBudget = 1024 (MB)
-
strictMeshMemory = false
-
private static LevelOfDetailQualitySettings lowQuality
Preset instance for the Low quality level. Values: - levelOfDetail = 0.35
- lodCrossFade = true
- maxLightCount = 2048
- meshMemoryBudget = 512 (MB)
-
strictMeshMemory = false
-
private static LevelOfDetailQualitySettings veryLowQuality
Preset instance for the Very Low quality level. Values: - levelOfDetail = 0.25
- lodCrossFade = false
- maxLightCount = 1024
- meshMemoryBudget = 256 (MB)
- strictMeshMemory = true
Note: The static constructor registers these presets with QualitySetting
Properties
public float levelOfDetail { get; set; }
Controls the global level-of-detail scalar used by the RenderingSystem. The UI slider is annotated with:-
min = 10f, max = 100f, step = 1f, unit = "percentage", scalarMultiplier = 100f This means the in-UI representation is 10–100% while the stored value is a float (e.g., 0.7 for 70%).
-
public bool lodCrossFade { get; set; }
Enable/disable LOD cross-fading in the RenderingSystem. -
public int maxLightCount { get; set; }
Maximum number of lights used by rendering. UI slider annotated: -
min = 512, max = 16384, step = 256
-
public int meshMemoryBudget { get; set; }
Mesh memory budget expressed in megabytes (MB) from the UI slider. UI annotation: -
min = 128, max = 4096, step = 64, unit = "dataMegabytes" When applied, this value is converted to bytes and assigned to the BatchMeshSystem.
-
public bool strictMeshMemory { get; set; }
If true, BatchMeshSystem.strictMemoryBudget is set, enforcing stricter budget behavior.
Constructors
-
public LevelOfDetailQualitySettings()
Default parameterless constructor. Initializes an empty settings object (properties default to their CLR defaults unless otherwise set). -
public LevelOfDetailQualitySettings(Level quality)
Constructs an instance and calls SetLevel(quality, apply: false) (inherited from QualitySetting<>) to populate properties from the registered preset for the given Level without immediately applying it to systems.
Methods
static LevelOfDetailQualitySettings()
Static constructor that registers preset instances with the QualitySetting registry:- Registers veryLowQuality for Level.VeryLow
- Registers lowQuality for Level.Low
- Registers mediumQuality for Level.Medium
-
Registers highQuality for Level.High
-
public override void Apply()
Applies the current settings to runtime systems: - Obtains the RenderingSystem from World.DefaultGameObjectInjectionWorld and, if present, sets:
- renderingSystem.levelOfDetail = levelOfDetail
- renderingSystem.lodCrossFade = lodCrossFade
- renderingSystem.maxLightCount = maxLightCount
- Obtains the BatchMeshSystem from World.DefaultGameObjectInjectionWorld and, if present, sets:
- batchMeshSystem.memoryBudget = (ulong)meshMemoryBudget * 1048576uL (converts MB to bytes)
- batchMeshSystem.strictMemoryBudget = strictMeshMemory
The method safely checks for the presence of the systems (null-check) before applying.
Usage Example
// Create settings from a preset and apply them immediately:
var settings = new LevelOfDetailQualitySettings(Level.High);
settings.Apply();
// Or modify individual properties and then apply:
var custom = new LevelOfDetailQualitySettings();
custom.levelOfDetail = 0.6f; // 60% LOD
custom.lodCrossFade = true;
custom.maxLightCount = 6000;
custom.meshMemoryBudget = 1536; // MB
custom.strictMeshMemory = false;
custom.Apply();
Additional notes: - The class is annotated for the settings UI with [SettingsUIAdvanced], [SettingsUISection("LevelOfDetailQualitySettings")], and [SettingsUIDisableByCondition(typeof(LevelOfDetailQualitySettings), "IsOptionsDisabled")], which affect how the setting is displayed and when it is enabled/disabled in the UI. - Apply() relies on Unity's World.DefaultGameObjectInjectionWorld to locate systems; if called outside a properly-initialized world context, the systems may be null and no runtime changes will be made.