Skip to content

Game.Settings.SettingsUIDescriptionAttribute

Assembly: Assembly-CSharp (game runtime assembly)
Namespace: Game.Settings

Type: class

Base: System.Attribute

Summary:
Attribute used to provide UI descriptions for settings. Can be applied to enum types or properties to supply either a static string override (an ID and/or a value) or a runtime-provided description via a getter method. The attribute is inherited by derived types (Inherited = true) and is intended to be read by the game's settings UI/reflection code to show labels or localized text for settings entries.


Fields

  • public readonly string id
    A string override for the description ID (commonly used as a localization key). When provided, UI code may use this as the lookup key instead of a generated/default key.

  • public readonly string value
    A string override for the description value. If supplied, this value can be used directly as the display text (or as a fallback if a localization lookup by id fails).

  • public readonly Type getterType
    Type that contains a method to dynamically provide the description. The method name is specified by getterMethod. The settings UI will use reflection to invoke the method on this type to obtain the description at runtime.

  • public readonly string getterMethod
    Name of the method on getterType that should be called to obtain the description. The expected method signature is determined by the code that invokes it (commonly a parameterless static method returning string, or a static method accepting the enum/property value and returning string).

Properties

  • None.

Constructors

  • public SettingsUIDescriptionAttribute(string overrideId = null, string overrideValue = null)
    Creates the attribute with optional id and/or value overrides. Use this when you want to supply a literal description or a localization key.

  • public SettingsUIDescriptionAttribute(Type getterType, string getterMethod)
    Creates the attribute specifying a type and method name that will be used to obtain the description at runtime. Use this when the description must be computed or localized dynamically.

Methods

  • None.

Usage Example

// Example 1: simple literal override (id and/or value)
[SettingsUIDescription(overrideId: "settings.graphics.quality", overrideValue: "Graphics Quality")]
public enum GraphicsQuality
{
    Low,
    Medium,
    High
}

// Or applied to a property:
public class MySettings
{
    [SettingsUIDescription(overrideValue: "Enable Shadows")]
    public bool EnableShadows { get; set; }
}

// Example 2: using a runtime getter
[SettingsUIDescription(typeof(DescriptionProvider), "GetGraphicsQualityDescription")]
public enum GraphicsQuality2
{
    Low,
    Medium,
    High
}

public static class DescriptionProvider
{
    // Common expected form: a static method returning a string.
    public static string GetGraphicsQualityDescription()
    {
        return "Select the overall quality level that controls textures, shadows and post-processing.";
    }

    // If the UI reflection expects a method that accepts the enum/value, you might implement:
    public static string GetValueDescription(object value)
    {
        // return description based on 'value'
        return value?.ToString() ?? string.Empty;
    }
}

Notes: - The attribute targets enums and properties (AttributeTargets.Enum | AttributeTargets.Property) and is inheritable. - How getterType/getterMethod are invoked (method signature requirements) depends on the settings UI/reflection implementation; common patterns are parameterless static methods returning string or static methods that accept the enum/property value and return string.