Input Glyphs
Show an input action's key on the device in use, following rebinds
Overview
Input Glyphs draw the key of an Input System action the way the player sees it: a key cap with its name on a keyboard, the button's picture on a gamepad, the mouse for a click. They follow the device the player used last and any rebinds, so a prompt never shows a key the player can't press.
Input Glyphs require the Input System package.
| Component | Description |
|---|---|
| Input Glyph | Draws the key of one action. |
| Input Glyph Hint | An action's key beside what it does, such as Interact. The supplied prefab is Input Glyph (Hint). |
| Input Glyph Hint List | A column of hints filled from code, for keys that change at runtime. |
| Input Glyph Set | An asset that sets how each control looks, like a font for keys. |
Usage
Select GameObject -> Evo UI -> Input -> Input Glyph or Input Glyph (Hint), or add one from the UI Catalog.
Assign Content -> Action. The supplied Glyph Set is Evo UI/Prefabs/Input/Default Input Glyphs.
Use the Preview As buttons to see the glyph on each device the set has glyphs for. Entering Play Mode draws it for the device in use.
For a hint, write what the action does in Words. A hint without an action shows its words alone, and a hint whose action has no binding on any device hides and takes no room in its layout.
Glyph Sets
A glyph set is a list of glyphs. Each glyph is one control, picked with the Input System's own control picker, the same one used for bindings. Select Listen in the picker and press a control to pick it.
| Field | Description |
|---|---|
| Control | The control and the device it belongs to, such as <Gamepad>/buttonSouth or <Mouse>/leftButton. |
| Shape | Key: a cap that grows with its label. Round: a round cap. Bare: the icon or label alone. |
| Content | Icon: the control's picture. Label: text, such as LMB for the left mouse button. |
| Icon | The picture shown with Icon content. Without one, the binding's own name is written. |
| Label | The text shown with Label content. Leave it empty to use the binding's own name. |
| Override Color | Colors the label or icon with Color. |
A device looks for its own glyph first, then the glyphs of the devices it is built on. A DualSense uses <DualShockGamepad> glyphs, and any pad without glyphs of its own uses the <Gamepad> ones. The supplied set has Xbox pictures under <Gamepad> and DualSense pictures under <DualShockGamepad>, so Xbox, Switch and other pads show Xbox buttons.
A control without a glyph is drawn as a key cap with the binding's own name, so every key a player can rebind to still shows. Keyboard keys use this by default.
Creating a Set
Duplicate the supplied set into your own folder, or create one from Create -> Evo -> UI -> Input Glyph Set, and assign it to your glyphs' Glyph Set field.
Any device the Input System knows can have glyphs, including touchscreens, pens and devices with layouts of your own: add a glyph and pick one of its controls. To give one controller its own pictures, pick its controls under its specific device, such as <XInputController> for Xbox controllers only.
If you change the glyphs list from code, call Refresh() on the set afterwards. Inspector changes are read automatically.
Colors
A glyph's parts keep the colors set on the prefab, from their Styler or their own color. Override Color paints the label or icon of that one glyph. In Play Mode it turns on the part's Styler Use Custom Color, and gives the Styler its color back when a glyph without an override is drawn.
Devices
The device in use is the last one that started or performed an action, so a resting gamepad's noise never takes over from the keyboard. A keyboard and a mouse count as one device: moving the mouse while typing changes nothing.
An action shows its first binding that serves the device in use: a binding of that device or of a device it is built on, so a <Gamepad> binding serves every pad. When no binding serves it, the first binding of another device is shown, dimmed to Other Device Alpha. A composite of one stick's directions is drawn as that stick. A composite of separate keys shows their names, such as W/A/S/D.
Binding overrides show at once. Overrides applied to actions that aren't enabled don't notify anything: call InputDeviceTracker.Refresh() after applying them.
To pin one device, such as a settings option for PlayStation prompts, set InputDeviceTracker.Forced to its layout name.
Hint Lists
Use Input Glyph Hint List when the keys change at runtime, such as the actions for the item a player holds. Assign Hint Prefab and Content, which needs a layout group, then call Show() with a list of hints. Rows are created the first time they're needed and reused after. Showing the same list again does nothing, so it is safe to call whenever something may have changed.
For keys that never change, place Input Glyph (Hint) prefabs directly instead, so their words stay editable in the scene or prefab.
Public API
All types are in the Evo.UI namespace.
Input Glyph
| Name | Type | Description |
|---|---|---|
Action | InputAction | The action drawn. Returns the referenced action until code sets another, such as a component's own action. |
GlyphSet | InputGlyphSet | The set the glyph's looks come from. |
HasBinding | bool | Whether the action has a binding on any device, so something is drawn. |
| Name | Parameters | Description |
|---|---|---|
Redraw() | None | Draws the key for the device in use. |
Draw() | string layout | Draws the key as it looks on a device layout, such as "DualShockGamepad". |
| Name | Type | Description |
|---|---|---|
Redrawn | event Action | Raised after each draw, for anything that follows the glyph's size or visibility. |
Input Glyph Hint
| Name | Type | Description |
|---|---|---|
Glyph | InputGlyph | The hint's glyph. |
| Name | Parameters | Description |
|---|---|---|
Set() | InputAction action, string text | Shows the action's key beside the text. With no action, shows the text alone. |
Set() | InputGlyphHintData hint | Shows a hint. |
Input Glyph Hint List
| Name | Type | Description |
|---|---|---|
Count | int | Number of hints shown. |
| Name | Parameters | Description |
|---|---|---|
Show() | IReadOnlyList<InputGlyphHintData> hints | Shows the hints, one row each, in order. |
Clear() | None | Shows no hints. |
Input Glyph Hint Data
A hint as code hands it over. Create these once per state, not every frame.
| Name | Parameters | Description |
|---|---|---|
InputGlyphHintData() | InputAction action, string words | A hint for an action. |
InputGlyphHintData() | InputActionReference action, string words | A hint for a referenced action. |
Input Glyph Set
| Name | Type | Description |
|---|---|---|
glyphs | List<Glyph> | The set's glyphs. |
| Name | Parameters | Description |
|---|---|---|
Find() | string layout, string control | The glyph for a control, such as "buttonSouth", on a device layout or the nearest layout it is built on. Null when the set has none. |
GetLayouts() | None | The device layouts the set has glyphs for. |
Refresh() | None | Reads glyphs again on the next Find(). |
Input Device Tracker
| Name | Type | Description |
|---|---|---|
Current | string | Layout of the device in use, or Forced while it is set. |
Forced | string | Pins a device layout whatever the player uses. Null follows the player. |
| Name | Parameters | Description |
|---|---|---|
Refresh() | None | Has every glyph read its binding's name and draw again. |
IsUsing() | string layout | Whether the device in use is the layout or built on it. IsUsing("Gamepad") is true for any pad. |
IsBasedOn() | string layout, string baseLayout | Whether a layout is another or built on it. |
BasesOf() | string layout | The layout followed by the layouts it is built on, nearest first, such as DualSenseGamepadHID, DualShockGamepad, Gamepad. |
ShownAs() | string device, string layout | The layout a control of layout is shown as while device is in use: the device itself when it is built on that layout, the keyboard or mouse for each other's controls, or null when the device doesn't serve it. |
UsedTogether() | string a, string b | Whether two layouts count as one device: the same layout, or a keyboard and a mouse. |
| Name | Type | Description |
|---|---|---|
Changed | static event Action | Raised when the device in use switches or bindings change. |
Input Glyph Lookup
| Name | Parameters | Description |
|---|---|---|
TryResolve() | InputAction action, string layout, InputGlyphSet set, out InputGlyphInfo info | The binding an action shows on a device and its glyph. False when the action has no binding. |
InputGlyphInfo holds the Glyph (null for a plain key cap), the binding's Label such as Esc, and OtherDevice, which is true when the binding belongs to another device. Its Text is what a glyph writes: the glyph's label when it shows one, otherwise Label. Use it to name a key in text.
Example
using UnityEngine;
using UnityEngine.InputSystem;
using Evo.UI;
public class InputGlyphExample : MonoBehaviour
{
[SerializeField] private InputGlyphHintList hints;
[SerializeField] private InputActionReference use;
[SerializeField] private InputActionReference drop;
private InputGlyphHintData[] holding;
private void Start()
{
// Build hints once per state, then show them when the state starts
holding = new[]
{
new InputGlyphHintData(use, "Use"),
new InputGlyphHintData(drop, "Drop")
};
}
public void OnPickedUp() => hints.Show(holding);
public void OnDropped() => hints.Clear();
public void SetPlayStationPrompts(bool on)
{
InputDeviceTracker.Forced = on ? "DualShockGamepad" : null;
}
}