Game.Settings.SettingsUITabOrderAttribute
Assembly:
Namespace: Game.Settings
Type: class
Base: System.Attribute
Summary:
An attribute used to define the order of UI tabs for a settings UI class. It supports either a static list of tab names provided at compile-time, or a reference to a type/method that can supply the tab names (for dynamic determination). The attribute is intended to be applied to classes (AllowMultiple = false).
Fields
-
public readonly ReadOnlyCollection<string> tabs
Holds a read-only collection of tab names supplied via the constructor that accepts string parameters. When set, these names represent the tab order for the target settings UI class. -
public readonly Type checkType
When provided, this is the Type that contains a method (named by checkMethod) which will be invoked to obtain the tab list dynamically. -
public readonly string checkMethod
The name of the method on checkType that should be called to retrieve the tabs. Typically this method is expected to return a string[] or ReadOnlyCollection(i.e., a collection of tab names), and often is implemented as a static method, but the attribute itself only stores the reference information.
Properties
This type defines no properties.
Constructors
-
public SettingsUITabOrderAttribute(params string[] tabs)
Initializes the attribute with an explicit, ordered list of tab names. The provided array is wrapped in a ReadOnlyCollection and stored in the tabs field. -
public SettingsUITabOrderAttribute(Type checkType, string checkMethod)
Initializes the attribute to use a delegate-style approach: checkType and checkMethod indicate where to obtain the tab names at runtime (or by whatever system consumes this attribute).
Methods
This type defines no methods.
Usage Example
// Static list of tabs (compile-time)
[SettingsUITabOrder("General", "Graphics", "Audio", "Controls")]
public class MySettingsUI
{
// ...
}
// Dynamic list via a provider type/method
public static class TabProviders
{
public static string[] GetTabsForMySettings() => new[] { "Main", "Advanced", "About" };
}
[SettingsUITabOrder(typeof(TabProviders), "GetTabsForMySettings")]
public class MyDynamicSettingsUI
{
// ...
}
Notes:
- The attribute is declared with [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] so it should be applied to classes only and cannot be applied multiple times.
- Consumer code that reads this attribute is responsible for invoking the specified checkMethod on checkType (if provided) and for handling the method signature (commonly a string[] or ReadOnlyCollection