Skip to content

Game.Settings.SettingsUIDisplayNameAttribute

Assembly:
(assembly not specified — typically part of the game's main assembly, e.g. Assembly-CSharp)

Namespace:
Game.Settings

Type:
public class

Base:
System.Attribute

Summary:
Attribute used to specify a UI display name for settings elements (enums or properties). It supports two modes: - Direct overrides by supplying an ID and/or a literal display value. - Indirect/runtime lookup by providing a Type and a method name that will return the display name(s).

This attribute can be applied to enum types and to individual properties. It is inheritable.


Fields

  • public readonly string id
    Identifier string that can be used as a resource key or unique id for the display name. When provided via the string-based constructor, this is set to the overrideId parameter.

  • public readonly string value
    Literal display value or override string. When provided via the string-based constructor, this is set to the overrideValue parameter.

  • public readonly Type getterType
    When using the delegate-style constructor, this stores the Type that contains the method to retrieve display names.

  • public readonly string getterMethod
    When using the delegate-style constructor, this stores the name of the method on getterType that will be invoked (or used) to obtain the display name(s).

Properties

  • (none)

Constructors

  • public SettingsUIDisplayNameAttribute(string overrideId = null, string overrideValue = null)
    Creates the attribute with direct override values. Use overrideId to provide a resource key or id, and overrideValue to provide a specific display text. Either parameter may be null.

  • public SettingsUIDisplayNameAttribute(Type getterType, string getterMethod)
    Creates the attribute that instructs the system to obtain display name(s) at runtime via a method. getterType identifies the type that exposes the method and getterMethod is the method name. The method is expected to be accessible in the context where it's invoked (usually static or instance resolved by the system).

Methods

  • (none)

Usage Example

// Direct override using id and/or value
[SettingsUIDisplayName(overrideId: "setting.showTraffic", overrideValue: "Show Traffic Density")]
public enum TrafficDisplayMode
{
    Off,
    Basic,
    Detailed
}

// Using a getter to resolve display names at runtime.
// The getterType should contain a method named "GetSettingName" (for example).
[SettingsUIDisplayName(typeof(SettingsDisplayNamesProvider), "GetSettingName")]
public enum SomeEnum
{
    OptionA,
    OptionB
}

// Example for a property
[SettingsUIDisplayName(overrideValue: "Enable Advanced Mode")]
public bool EnableAdvancedMode { get; set; }

Notes: - AttributeTargets: this attribute applies to enums and properties (AttributeTargets.Enum | AttributeTargets.Property). - Inherited: true — the attribute will be inherited by derived types where applicable. - Behavior of the getter-based constructor (how/when the method is invoked, whether it must be static, expected return type/signature) is determined by the consuming settings/UI system; ensure your provider method matches the expectations of that system.