Game.Settings.SettingsUIDropdownAttribute
Assembly: Assembly-CSharp.dll
Namespace: Game.Settings
Type: class
Base: System.Attribute
Summary:
Attribute used to mark a settings property so the UI can render it as a dropdown. The attribute points to a type and method that supply the list of items for the dropdown. The attribute is applicable to properties and is inherited by derived types (AttributeUsage(AttributeTargets.Property, Inherited = true)).
Fields
-
public readonly System.Type itemsGetterType
Type that contains the method used to obtain dropdown items. The method referenced by itemsGetterMethod is expected to be found on this type (commonly a static helper/provider class). -
public readonly string itemsGetterMethod
Name of the method on itemsGetterType that returns the collection of items to populate the dropdown. Typically this is the name of a static method; the exact expected return type depends on the UI implementation (commonly array or IEnumerable of strings or option objects).
Properties
- This attribute does not declare any C# properties (only readonly fields).
Constructors
public SettingsUIDropdownAttribute(Type itemsGetterType, string itemsGetterMethod)
Creates a new SettingsUIDropdownAttribute pointing at the provided type and method name. Both parameters are stored in the readonly fields itemsGetterType and itemsGetterMethod so the UI/system can invoke the method to retrieve dropdown entries.
Methods
- This attribute declares no methods besides the constructor.
Usage Example
public static class SettingsDropdownProviders
{
// Example provider method returning string items
public static string[] GetQualityOptions()
{
return new[] { "Low", "Medium", "High" };
}
// Alternatively, could return IEnumerable<string> or a more complex option type
// public static IEnumerable<(string value, string display)> GetComplexOptions() { ... }
}
public class GraphicsSettings
{
[SettingsUIDropdown(typeof(SettingsDropdownProviders), nameof(SettingsDropdownProviders.GetQualityOptions))]
public string Quality { get; set; }
}
Notes:
- The AttributeUsage on the class restricts usage to properties and allows inheritance.
- The UI/system consuming this attribute is responsible for invoking the target method (usually via reflection) and handling the returned collection format. Ensure the method signature and return type match what the consumer expects (commonly static methods returning string[] or IEnumerable