Game.Settings.SettingsUIGroupOrderAttribute
Assembly: Assembly-CSharp
Namespace: Game.Settings
Type: class
Base: System.Attribute
Summary:
An attribute used to specify the order (or ordering provider) of UI groups for a settings UI class. Apply to a settings UI class to define a fixed order of group names, or provide a type and method name that will be queried to produce the ordering at runtime. The attribute is restricted to classes and cannot be applied multiple times to the same class (AttributeUsage(AttributeTargets.Class, AllowMultiple = false)).
Fields
-
public readonly ReadOnlyCollection<string> groups
Holds a read-only collection of group names supplied via the params string[] constructor. Use this when you want to declare a fixed ordering of groups directly on the attribute. -
public readonly Type checkType
Holds a Type that contains a method (named by checkMethod) used to determine or provide the group ordering at runtime. Intended for dynamic or computed ordering logic. -
public readonly string checkMethod
Name of the method on checkType which will be used to determine group ordering. The attribute only stores the method name; the consuming code is expected to locate and invoke that method. Typically the method is implemented as a public static method returning a string[] / IEnumerable/ ReadOnlyCollection (or similar), but exact expected signature depends on the code that consumes this attribute.
Properties
- This type does not declare any properties.
Constructors
-
public SettingsUIGroupOrderAttribute(params string[] groups)
Creates the attribute with an explicit, fixed ordering of group names. The provided string array is wrapped in a ReadOnlyCollectionand stored in the groups field. -
public SettingsUIGroupOrderAttribute(Type checkType, string checkMethod)
Creates the attribute that points to a type and method name to be used to determine group ordering at runtime. Use this when order must be computed or retrieved from code rather than declared statically.
Methods
- This attribute type does not declare any methods beyond constructors. Any runtime behavior (invoking the check method) is expected to be implemented by the code that reads this attribute.
Usage Example
// Static (fixed) order
[SettingsUIGroupOrder("General", "Graphics", "Audio")]
public class MySettingsUI
{
// Settings UI implementation...
}
// Dynamic order via provider type/method
[SettingsUIGroupOrder(typeof(MyGroupOrderProvider), "GetGroupOrder")]
public class MySettingsUI2
{
// Settings UI implementation...
}
public static class MyGroupOrderProvider
{
// Typical signature: returns an array or IEnumerable<string> of group names.
public static string[] GetGroupOrder()
{
return new[] { "General", "Audio", "Graphics" };
}
}
Notes for modders: - AttributeUsage restricts this attribute to classes and prevents multiple instances on the same class. - If using the type/method overload, ensure the method name provided exists on the type and is accessible to the code that will invoke it (commonly public static). The exact expected return type and invocation conventions depend on the consuming system in the game/mod framework.