Skip to content

Game.Settings.SettingsUISliderAttribute

Assembly: Assembly-CSharp.dll
Namespace: Game.Settings

Type: class

Base: System.Attribute

Summary:
Attribute used to annotate settings properties so they are rendered as sliders in the game's settings UI. Configure range, step, display unit and how the UI should scale and update values while dragging.


Fields

  • public float min
    Minimum slider value. Defaults to 0.0 (implicit). Use to set the lower bound for the slider.

  • public float max = 100f
    Maximum slider value. Defaults to 100.0. Use to set the upper bound for the slider.

  • public float step = 1f
    Step/increment for the slider. Defaults to 1.0. Controls snapping or quantization of values when the user drags the slider.

  • public string unit = "integer"
    Unit string used for display beside the slider value. Default is "integer". Use values like "%", "s", "km/h", or custom labels to show the meaning of the value.

  • public float scalarMultiplier = 1f
    Multiplier applied when presenting or interpreting the value in the UI. For example, set to 100 to display a 0..1 internal value as 0..100 in the UI.

  • public bool scaleDragVolume
    If true, adjust the slider drag sensitivity/volume based on the scalarMultiplier (or other internal scaling). Default false. Useful when UI should account for scaled display values when dragging.

  • public bool updateOnDragEnd
    If true, the setting only commits/updates when the user finishes dragging (on drag end). If false, the setting updates continuously as the slider is dragged. Default false.

Properties

  • None.

Constructors

  • public SettingsUISliderAttribute()
    Implicit parameterless constructor. All configuration is done via public fields on the attribute after construction or via attribute initializer syntax.

Methods

  • None.

Usage Example

// Display a float property as a percentage slider from 0% to 100% with 0.5% steps,
// showing the UI value as 0..100 while storing the internal value as 0..1.
[SettingsUISlider(min: 0f, max: 100f, step: 0.5f, unit: "%", scalarMultiplier: 0.01f, scaleDragVolume: true, updateOnDragEnd: false)]
public float TrafficFlowMultiplier { get; set; }

// Simple integer-style slider
[SettingsUISlider(min: 1f, max: 10f, step: 1f, unit: "levels")]
public int DifficultyLevel { get; set; }