Game.Settings.SettingsUICustomFormatAttribute
Assembly: Assembly-CSharp
Namespace: Game.Settings
Type: public class SettingsUICustomFormatAttribute
Base: System.Attribute
Summary:
Attribute applied to properties to control how numeric values are formatted in the settings UI. Targets properties (AttributeTargets.Property) and is inheritable. Contains simple, public fields that specify fraction digit count, thousand-separator behavior, the maximum value for which fractional digits are shown, and whether the value may be signed. This attribute is metadata only — the UI code must read these fields and apply the formatting.
Fields
-
public int fractionDigits
Number of fractional decimal digits to display (e.g., 2 → show two digits after the decimal point). Default is 0 (the field is an int and not initialized explicitly). -
public bool separateThousands = true
When true, format numbers with thousand separators (e.g., "1,234"). Default: true. -
public float maxValueWithFraction = 100f
Maximum value for which fractional digits should be shown. For values greater than this threshold UIs may omit fractional digits (implementation-defined). Default: 100f. -
public bool signed
When true, indicates values may be signed (allow/display a leading minus sign). Default: false.
Properties
- This class defines no properties; it exposes public fields that are used by UI formatting logic.
Constructors
public SettingsUICustomFormatAttribute()
Default constructor (compiler-generated). The attribute's fields use their declared defaults: fractionDigits = 0, separateThousands = true, maxValueWithFraction = 100f, signed = false.
Methods
- This attribute type declares no methods beyond those inherited from System.Attribute / System.Object.
Usage Example
// Apply to a numeric setting property to control how it's shown in the settings UI.
[SettingsUICustomFormat(fractionDigits = 2, separateThousands = true, maxValueWithFraction = 100f, signed = false)]
public float RoadTollAmount { get; set; }
// Example: show two decimal places for values <= 100, include thousand separators,
// and treat value as unsigned.
[SettingsUICustomFormat(fractionDigits = 2, separateThousands = true, maxValueWithFraction = 100f, signed = false)]
public float SomeSmallDecimalSetting { get; set; }
Notes: - The attribute itself only carries formatting metadata. The settings UI implementation must read these fields and apply the formatting accordingly. - AttributeUsage: AttributeTargets.Property, Inherited = true.