GamepadGlyph and InputGlyph
A GamepadGlyph shows one gamepad button as a glyph, in the look of an Xbox, a PlayStation or a Switch gamepad. An InputGlyph shows any other input glyph: a mouse button, a key or a device. Use them in a button prompt, a tutorial, a key binding list or a quick time event. They only show the input; they do not listen for it.


<tb:GamepadGlyph button="South" family="Xbox" />
<tb:GamepadGlyph button="LeftShoulder" family="PlayStation" />
<tb:GamepadGlyph
button="East"
family="Xbox"
class="tb-gamepad-glyph--colored" />
<tb:GamepadGlyph button="South" progress="0.6" />
<tb:GamepadGlyph button="South" auto-family="true" />
<tb:GamepadGlyph
button="West"
auto-family="true"
keyboard-glyph="keyboard-x" />
<tb:InputGlyph glyph="mouse-left" />
<tb:InputGlyph glyph="keyboard-enter" />
row.Add(new GamepadGlyph(GamepadGlyphButton.South, GamepadFamily.Xbox));
row.Add(new InputGlyph("mouse-left"));
row.Add(new InputGlyph(PromptFont.KEYBOARD_ENTER));
// The glyph of a binding, in the look of the gamepad of the player
if (GamepadGlyph.TryGetButton("<Gamepad>/buttonSouth", out var button))
glyph.Button = button;
glyph.Family = GamepadGlyph.FamilyOf(Gamepad.current.layout);
// A glyph that follows the device the player used last: Enter on the
// keyboard, A, a cross or B on a gamepad
glyph.AutoFamily = true;
// A button that the player holds
glyph.Progress = heldSeconds / HOLD_SECONDS;
GamepadGlyph
| Member | Description |
|---|---|
Button (button) |
The button, a GamepadGlyphButton (default South). |
Family (family) |
The look, a GamepadFamily: Generic (default), Xbox, PlayStation or Switch. |
AutoFamily (auto-family) |
The glyph follows the device that the player used last. After a gamepad button it shows Button in the family of that gamepad. After a key or a mouse button it shows the key of KeyboardGlyph. Off by default: the glyph shows Button in Family. See "Follow the last used device". |
KeyboardGlyph (keyboard-glyph) |
With AutoFamily: the glyph for the keyboard and the mouse, a PromptFont name such as "keyboard-e" or "mouse-left". Empty (default) shows the key that the toolbox controls use for the button. |
Action (code only) |
An InputAction of the game. The glyph shows the binding of the action, so a rebind shows at once: its gamepad binding in place of Button, and with AutoFamily its keyboard or mouse binding in place of KeyboardGlyph. Null (default) shows Button and KeyboardGlyph. Needs the Input System package. |
Progress (progress) |
The part of the ring around the glyph that shows, from 0 to 1. See InputGlyph. |
GamepadGlyph.TryGetButton(controlPath, out button) |
Gives the button of an Input System control path, such as "<Gamepad>/buttonSouth" or "<Gamepad>/dpad/up". False for a path that is not a gamepad button. |
GamepadGlyph.FamilyOf(device) |
Gives the family of a device from its layout name or its display name, such as "DualSenseGamepadHID" or "Xbox Controller". An unknown name gives Generic. |
The values of GamepadGlyphButton are the control names of the Unity Input System:
| Buttons | Values |
|---|---|
| Face buttons | South, East, West, North |
| D-pad | DpadUp, DpadDown, DpadLeft, DpadRight, Dpad (the full d-pad) |
| Shoulders and triggers | LeftShoulder, RightShoulder, LeftTrigger, RightTrigger |
| Sticks | LeftStick, RightStick, LeftStickPress, RightStickPress |
| Menu buttons | Start, Select |
- The south button is "A" on an Xbox gamepad, a cross on a PlayStation gamepad and "B" on a Switch gamepad.
Buttonis the place of the button, so one value is correct for each gamepad. - A family with no own glyph for a button shows the generic glyph. The sticks have one look for all families.
StartandSelectare the Menu and View buttons of an Xbox gamepad, the Options and Create buttons of a DualSense, and Plus and Minus of a Switch gamepad.- Both functions take a text, so they work without the Input System package.
Follow the last used device
A glyph with AutoFamily shows the button that the player can press now. A game for the keyboard, the mouse and gamepads then needs one glyph for each prompt, not a glyph for each device.
<!-- Enter on the keyboard, A on an Xbox gamepad, a cross on a
PlayStation gamepad, B on a Switch gamepad -->
<tb:GamepadGlyph button="South" auto-family="true" />
The key of a glyph with an empty KeyboardGlyph:
| Button | Key |
|---|---|
South |
Enter |
East, Start |
Escape |
LeftShoulder, RightShoulder |
Q, E |
DpadUp, DpadDown, DpadLeft, DpadRight |
The arrow key |
Dpad, LeftStick |
The four arrow keys |
| Any other button | None. The glyph is hidden while the keyboard is the last device, unless KeyboardGlyph has a name. |
One tracker, LastInputDevice, tells every AutoFamily glyph, PromptBar, InteractionPrompt and NavigableTabView with BumperSwitch which device the player used last.
| Member | Description |
|---|---|
LastInputDevice.IsGamepad |
True when the player used a gamepad last. False for the keyboard and mouse, also before the first press. |
LastInputDevice.Family |
The GamepadFamily of that gamepad. Generic while IsGamepad is false. |
LastInputDevice.Changed |
Raised when IsGamepad or Family changes. |
LastInputDevice.AutoDetect |
True (default): the tracker follows the input. False: the tracker ignores the input, and only Set changes the device. Use it for an option such as "Glyphs: Auto, Xbox, PlayStation, Switch, Keyboard". |
LastInputDevice.Set(gamepad, family) |
Sets the device by hand. Use it for a fixed choice of the player, and for input that the Input System package does not read. |
LastInputDevice.Retain(), Release() |
Keep the tracker running without a glyph on a panel. Each Retain needs a Release. A glyph with AutoFamily does this by itself while it is on a panel. |
- With the Input System package the tracker reads the devices after each update of the Input System, and only while a control that needs it is on a panel. It allocates no memory.
- A button, a trigger, the d-pad or a stick pushed to a side on a gamepad switches to that gamepad and its family. A key or a mouse button switches to the keyboard. A moved mouse and a small tilt of a stick switch nothing.
- A device with a gamepad and no keyboard, such as a console, starts with the gamepad. The other devices start with the keyboard.
- Without the Input System package nothing switches the device by itself. Call
LastInputDevice.Setfrom your input code, for exampleLastInputDevice.Set(true, GamepadFamily.Xbox)when a button of a gamepad goes down andLastInputDevice.Set(false)for a key. - A fixed choice of the player is
LastInputDevice.AutoDetect = falseandLastInputDevice.Set(...). SetAutoDetectback to true for the choice "Auto". - The family of a gamepad comes from its layout name or its display name, as
GamepadGlyph.FamilyOfreads them. An unknown gamepad isGeneric.
InputGlyph


GamepadGlyph is an InputGlyph. Use an InputGlyph for a glyph that is not in the button list.
| Member | Description |
|---|---|
Glyph (glyph) |
The PromptFont name of the glyph, such as "mouse-left", "keyboard-enter", "analog-l-up" or "device-gamepad". A text that is not a name shows as it is, so a PromptFont constant works too. The Inspector has a ComboBox that shows each glyph beside its name, and a preview. |
Progress (progress) |
The part of the ring around the glyph that shows, from 0 to 1 (default 0). The ring fills clockwise from the top. 0 shows no ring. |
PromptFont.<NAME> |
A constant for each glyph: the character of the glyph, such as PromptFont.MOUSE_LEFT. |
PromptFont.Names |
The names of all glyphs. |
PromptFont.TryGetGlyph(name, out glyph) |
Gives the character of a name. False for a name that the list does not have. |
PromptFont.Matches(name, query) |
True when every typed word is part of the name or of its search words (family, button name, common words), in any order. PlayStation Square finds sony-x. |
- The names are the code names of PromptFont. The list has the glyphs of the gamepads, the keys, the mouse and the devices. The glyph page of PromptFont shows each glyph with its name: https://shinmera.com/promptfont
- The name of a constant is the name of the glyph in capital letters with "_" for "-": "xbox-a" is
PromptFont.XBOX_A. - The glyph is text. The USS
coloris its color and the USSfont-sizeis its size (default 20 px). - The ring is outside of the box of the glyph, so the glyph does not move when the ring shows. Give the glyph a margin of about 8 px when it has a ring. A parent with
overflow: hiddencuts the ring. - A glyph has one color. The letter in a button is a hole, so the background shows through it.
Tips:
- Use a Kbd for a keyboard shortcut in a text or a menu: it shows any key name as a cap in the font of the theme. Use an
InputGlyphfor a prompt in a game, where the mouse, the keys and the gamepad buttons have the same look. - Turn
AutoFamilyon for a prompt that the player reads while playing. The prompt then shows the keys or the buttons of the gamepad in the hands of the player, and changes when the player changes the device. SetFamilyyourself for a glyph that always shows one gamepad, such as a picture of a controller in a tutorial. - A PromptBar shows a row of glyphs with a text for each, and an InteractionPrompt shows one in the world.
- For a hold or a quick time event, set
Progresseach frame from the time. Set it back to 0 when the player releases the button. - For a glyph in a sentence, put the labels and the glyph in a row with
flex-direction: rowandalign-items: center.
In the examples


Styling
| Class or property | Element |
|---|---|
tb-input-glyph |
The glyph. color is the color and font-size is the size. |
tb-input-glyph__text |
The text element with the PromptFont font. |
--tb-input-glyph-ring-color |
A custom property on the glyph: the color of the filled part of the ring (--tb-color-accent). |
--tb-input-glyph-ring-track |
A custom property on the glyph: the color of the rest of the ring (--tb-color-border). A transparent color draws no track. |
--tb-input-glyph-ring-width |
A custom property on the glyph: the width of the ring in pixels (3). |
tb-gamepad-glyph |
On each GamepadGlyph. |
tb-gamepad-glyph--generic, --xbox, --playstation, --switch |
The family. |
tb-gamepad-glyph--south, --left-shoulder, --dpad-up, ... |
The button: its name in small letters with "-" between the words. |
tb-gamepad-glyph--colored |
Opt-in. Add it to a glyph for the colors of the face buttons of an Xbox or a PlayStation gamepad. The other buttons keep color. |
tb-gamepad-glyph--keyboard |
Replaces the family class while an AutoFamily glyph shows a key. |
tb-gamepad-glyph--empty |
An AutoFamily glyph that has no key to show. It is display: none. |
.prompt .tb-input-glyph {
font-size: 32px;
color: var(--tb-color-accent);
}
.prompt .tb-input-glyph {
--tb-input-glyph-ring-color: var(--tb-color-success);
--tb-input-glyph-ring-width: 4;
}
.prompt .tb-gamepad-glyph--south { color: var(--tb-color-success); }
The GamepadGlyphDemo scene shows each button in each family, the button hints of an inventory that follow the gamepad of the player, a hold prompt that opens a chest and a glyph that follows a gamepad binding. The InputGlyphDemo scene shows a tutorial whose prompts follow the device that the player uses, the looks of an InputGlyph and all the PromptFont glyphs with a search field.
License
- The glyphs are from the font PromptFont by Yukari "Shinmera" Hafner, under the SIL Open Font License 1.1. The font and its license are in
Runtime/Resources/UIToolbox/Fonts. SeeThird Party Notices.md. - The shapes and the logos of the buttons of a platform are trademarks of their owners. The license of the font does not give a right to them.
- When you ship a build for a console, follow the rules of the platform holder for button art.