Game.Settings.SettingsUIInputActionAttribute
Assembly:
Assembly-CSharp.dll
{{ This attribute is defined in the game assembly (commonly Assembly-CSharp). If you build a mod assembly, reference the game's assembly that contains Game.Settings. }}
Namespace: Game.Settings
Type:
abstract class
{{ This attribute is declared as abstract — it is intended to be subclassed to create concrete attributes for specific UI input actions (e.g., keybind attributes). }}
Base:
System.Attribute
Summary:
An attribute that describes metadata for a settings UI input action. It carries information used by the settings system and input binding UI such as the action name, target device, action type, whether modifiers are allowed, developer-only flag, input mode, interactions and processors, and any custom usages. The attribute is abstract so concrete attributes should derive from it and supply appropriate constructor arguments.
Fields
-
public readonly string name
{{ Human-readable name/identifier for the input action. Typically used by the settings UI to identify the action (e.g., "ToggleMap"). }} -
public readonly InputManager.DeviceType device
{{ The input device type this action belongs to (e.g., Keyboard, Mouse, Gamepad). Uses the game's InputManager.DeviceType enum. }} -
public readonly ActionType type
{{ The action type (e.g., Button, Value, PassThrough) — taken from the game's ActionType enum — indicating how the input is interpreted. }} -
public readonly bool allowModifiers
{{ Whether modifier keys (Shift/Ctrl/Alt) are allowed for this action. True means modifiers can be used/recorded as part of the binding. }} -
public readonly bool developerOnly
{{ If true, the action is intended only for developer/debug usage and can be hidden from normal players in the UI. }} -
public readonly Mode mode
{{ The input mode/context this action applies to (for example Gameplay, UI, etc.). Uses the game's Mode enum to scope bindings. }} -
public readonly ReadOnlyCollection<string> interactions
{{ A read-only collection of interaction names (string) associated with the action (may be empty). Interactions modify how input is interpreted, e.g., hold/press behaviors. }} -
public readonly ReadOnlyCollection<string> processors
{{ A read-only collection of processor names (string) to post-process input values (may be empty). }} -
private readonly string[] customUsages
{{ Internal storage for custom usage strings passed to the attribute. These are used to build the Usages returned by the usages property. }}
Properties
public Usages usages { get; }
{{ Returns a Usages instance describing the usage hints for the input action. If customUsages were provided to the attribute, this property returns a new Usages(readOnly: true, customUsages). Otherwise it returns Usages.defaultUsages. This is used by the input system/UI to decide how to present/interpret the binding. }}
Constructors
-
protected SettingsUIInputActionAttribute(string name, InputManager.DeviceType device, ActionType type, bool allowModifiers, bool developerOnly, Mode mode, string[] customUsages, string[] interactions, string[] processors)
{{ Primary protected constructor. Initializes all fields. The interactions and processors arrays are wrapped into ReadOnlyCollection(empty if null). customUsages is stored (empty if null). Use this when you need full control over allowModifiers, developerOnly and lists of interactions/processors. }} -
protected SettingsUIInputActionAttribute(string name, InputManager.DeviceType device, ActionType type, Mode mode, string[] customUsages)
{{ Convenience protected constructor that sets allowModifiers = true and developerOnly = false, and sets interactions/processors to empty arrays. Useful for simple attribute subclasses where modifiers are allowed by default and the action is not developer-only. }}
Methods
- None (no additional public or virtual methods)
{{ The class only exposes readonly fields and the usages property. Behavior is established at construction time and consumed by the settings/input systems. }}
Usage Example
// Create a concrete attribute deriving from the abstract base:
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public sealed class KeybindAttribute : SettingsUIInputActionAttribute
{
public KeybindAttribute(string name, InputManager.DeviceType device, ActionType type, Mode mode, string[] customUsages = null)
: base(name, device, type, mode, customUsages)
{
}
}
// Apply the concrete attribute to a settings property:
[Keybind("ToggleMap", InputManager.DeviceType.Keyboard, ActionType.Button, Mode.Gameplay)]
public string ToggleMapKey { get; set; }
{{ Notes: - Because SettingsUIInputActionAttribute is abstract, you must subclass it to create a usable attribute. - Provide interactions/processors or set developer-only/allowModifiers via the full constructor when needed. - The Usages property will return either the provided custom usages (wrapped readonly) or the global default usages. }}