Game.Settings.SettingsUIKeybindingAttribute
Assembly: Assembly-CSharp (typical for game code / mods)
Namespace: Game.Settings
Type: abstract class
Base: System.Attribute
Summary:
Attribute base used to describe a keybinding displayed in the Settings UI. Instances (concrete subclasses) carry metadata about a particular input action: the engine action name, the input device type, the action type and the action component. Concrete attributes must supply the actual control identifier and any modifier controls. This attribute is intended for reflection-based UI/Settings systems to enumerate and present keybindings for remapping or display.
Fields
-
public readonly string actionName
Name of the input action this attribute refers to (engine action identifier used by the input system). This value is provided to the constructor and cannot be changed afterward. -
public readonly InputManager.DeviceType device
The device type (keyboard, mouse, gamepad, etc.) for this binding. See InputManager.DeviceType for possible values. Provided in the constructor and read-only. -
public readonly ActionType type
Logical action type (e.g., Button, Axis, Toggle — depending on the game's ActionType enum). Indicates how the input should be treated. Read-only and set via constructor. -
public readonly ActionComponent component
Component or sub-part of the action (depending on the game's ActionComponent enum). Read-only and set via constructor.
Properties
-
public abstract string control { get; }
Returns the concrete control identifier (for example a key name, button id or axis name) that maps to the action. Concrete subclasses must implement this property to provide the main control for the binding. -
public abstract IEnumerable<string> modifierControls { get; }
Returns zero or more modifier control identifiers (e.g., "LeftShift", "RightCtrl") required in combination with the main control. Concrete subclasses must implement this to enumerate any modifier keys/buttons.
Constructors
protected SettingsUIKeybindingAttribute(string actionName, InputManager.DeviceType device, ActionType type, ActionComponent component)
Creates a new attribute instance with the provided metadata.- actionName: the name of the input action in the input system.
- device: which input device this binding applies to.
- type: semantic action type (button/axis/toggle etc.).
- component: action component/subtype. The constructor is protected because this class is abstract — derive a concrete attribute class that implements the abstract properties.
Methods
- None (this class only exposes readonly fields, abstract properties, and a protected constructor)
Usage Example
// Concrete attribute that binds the "Jump" action to Space with LeftShift as a modifier
public sealed class JumpKeybindingAttribute : Game.Settings.SettingsUIKeybindingAttribute
{
public JumpKeybindingAttribute()
: base("JumpAction", InputManager.DeviceType.Keyboard, ActionType.Button, ActionComponent.Primary)
{
}
// Main control for this binding (string format depends on input system expectations)
public override string control => "Space";
// Optional modifiers (can be empty)
public override IEnumerable<string> modifierControls => new[] { "LeftShift" };
}
// Example of applying the attribute to a setting or field that the settings UI will reflect over.
// How the attribute is consumed depends on the settings system — typically reflection will read the attribute
// to display or register the keybinding in the UI.
[JumpKeybinding]
public object SomeSettingsPlaceholder;
Notes and recommendations: - Implementations must follow the input system's expected control name conventions (the string values for control and modifierControls must match what InputManager expects). - The enums InputManager.DeviceType, ActionType and ActionComponent are defined elsewhere in the game's input code — consult those definitions to choose appropriate values. - Because this class is an attribute, you may also want to add AttributeUsage to your concrete attribute classes if you need to restrict where they can be applied (property, field, method, etc.).