Class HotkeyKeyMap
The keys that drive the hotkey bars: one key per position, one modifier per extra bar.
public static class HotkeyKeyMap
- Inheritance
-
HotkeyKeyMap
- Inherited Members
Remarks
Previously a static method on the uGUI UIHotkeyBar that named twelve inputs. It is not
a rendering concern — it names input bindings — and the UI Toolkit hotkey bar needs it, so it
moved out of the uGUI tree rather than being duplicated into it.
Positions. Left and right mouse, then the Hotkey1..Hotkey0 actions of the
input asset, drive positions 0 to 11 of whichever bar a press lands on (see
HotkeyBarLayout for which). The mouse buttons are read directly, as they always
were: they are the attack buttons of the world view, not rows in the Key Bindings tab.
Bar modifiers are created here, at run time. How many bars there are is a game setting
(HotkeyBarCount), so the actions cannot be authored into
the input asset for every game: one HotbarNModifier per extra bar, plus a page up and
page down pair for the paged layout, are added to the Player map when the controls are
created — before any map is enabled, and before the saved overrides are applied, so the Key
Bindings tab lists and rebinds them like any authored action. A single-bar game adds none.
Defaults, and why not Shift. The second bar's modifier is Ctrl and the third's Alt; neither is bound to anything else. Shift is Sprint, so a Shift bar would fire whenever a sprinting player pressed a number — the overlap this scheme exists to avoid — and the fourth bar onwards start unbound: clickable, and given a key in Options if the player wants one.
Stable binding ids. Saved overrides are matched to bindings by binding id and by
nothing else (LoadBindingOverridesFromJson), and a binding added at run time gets a
fresh random id every launch unless it is given one. Each binding's id is therefore derived
from its action's name, so a rebound modifier is still rebound at the next login.
Fields
PageDownActionName
Name of the action that pages a paged hotbar down to the previous bar.
public const string PageDownActionName = "HotbarPageDown"
Field Value
PageUpActionName
Name of the action that pages a paged hotbar up to the next bar.
public const string PageUpActionName = "HotbarPageUp"
Field Value
Methods
AddBarActions(PlayerControls)
Adds the bar modifier and page actions to the Player map. Idempotent.
public static void AddBarActions(PlayerControls controls)
Parameters
controlsPlayerControlsFreshly created controls whose maps are not yet enabled.
Remarks
Must run before any map is enabled — an enabled map refuses new actions — and before the
saved overrides are loaded, or the overrides for these bindings find nothing to apply to.
PlayerInputController.EnsureControlsCreated calls it between the two.
AddBarActions(InputActionMap, int)
AddBarActions(PlayerControls) for a given map and bar count, so the actions and the survival of their overrides can be tested for several bars in a game that ships one.
public static void AddBarActions(InputActionMap map, int bars)
Parameters
mapInputActionMapThe Player action map, not yet enabled.
barsintHow many bars to create modifiers for.
FirstHeldModifierBar()
The first bar, in bar order from the second, whose modifier is held; -1 when none is.
public static int FirstHeldModifierBar()
Returns
IsPageDownPressed()
Whether the page down key is down.
public static bool IsPageDownPressed()
Returns
IsPageUpPressed()
Whether the page up key is down.
public static bool IsPageUpPressed()
Returns
IsPositionPressed(int)
Whether the key for a position is down.
public static bool IsPositionPressed(int position)
Parameters
positionintZero-based position on a bar.
Returns
ModifierActionName(int)
The action name of a bar's modifier.
public static string ModifierActionName(int bar)
Parameters
barintZero-based bar index, from 1.
Returns
SlotLabel(int, int)
The key hint drawn in a slot's corner: the position's key, prefixed with the bar's modifier after the first bar.
public static string SlotLabel(int bar, int position)
Parameters
Returns
- string
The hint, or empty when no key reaches the slot.
Remarks
Read from the live bindings, so a rebind shows on the bar — it used to be a fixed table, and a player who moved slot 1 to Q still saw "1" on it. A bar whose modifier is unbound shows nothing: no key reaches it, and "1" would claim one did.
TryGetDisplayName(string, out string)
The player-facing caption of an action this class creates, for the Key Bindings tab.
public static bool TryGetDisplayName(string actionName, out string displayName)
Parameters
actionNamestringThe action's name.
displayNamestringThe caption, when the action is one of these.
Returns
- bool
True when the action is a bar modifier or a page action.