InputBinding
Updated a year agoInputBinding class
This utility handles registering and managing a player input binding.
Example Usage
public static ConfigEntry<KeyCode> DoTheThingKey;
private static InputBinding sDoTheThingBinding;
private void Awake()
{
DoTheThingKey = Config.Bind("MyMod", nameof(DoTheThingKey), KeyCode.Backspace, "Binds a shortcut key for doing the thing.");
sDoTheThingBinding = new InputBinding("MyMod_DoTheThing", DoTheThingKey);
sDoTheThingBinding.InputPressed += DoTheThingBinding_InputPressed;
}
private void DoTheThingBinding_InputPressed(object sender, InputEventArgs e)
{
// Do whatever you want to do in response to the player activating the bound input
// The event args param 'e' contains a reference to the current Player if needed.
}
Note: Registered bindings currently only work in-world, not in the main menu.