> For the complete documentation index, see [llms.txt](https://fast-studios.gitbook.io/input-hub/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fast-studios.gitbook.io/input-hub/manual/prompts.md).

# Prompts

Show the player which button to press, with the icon of the device they are using.

A **prompt** tells the player which button to press: the "**E** Open" over a door, the "**A** Jump" in a tutorial, the list of controls in a pause menu. Input Hub draws prompts with the icon of the device the player is using right now, and changes them the moment the player switches devices, rebinds a key or changes the language.

## The Prompt Components

| Component                                                                   | Use it for                                                                                                |
| --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [**Input Prompt**](/input-hub/manual/prompts/input-prompt.md)               | Most prompts. Text with icons on a Canvas: "{Interact} Open".                                             |
| [**Input Prompt Text**](/input-hub/manual/prompts/input-prompt-text.md)     | A text you already have, like a dialog line or a tutorial, with the key names or icons written inside it. |
| [**Input Prompt Icon**](/input-hub/manual/prompts/input-prompt-icon.md)     | Just the icon of one action on an Image, for layouts you build yourself.                                  |
| [**Input Prompt Sprite**](/input-hub/manual/prompts/input-prompt-sprite.md) | A prompt in the world, outside any Canvas, like a key floating over a chest.                              |

And a few helpers:

* [**Prompt Variations**](/input-hub/manual/prompts/prompt-variations.md): how keys look in every prompt. Icon or text, short or long names, where "Hold" goes.
* [**Key Shapes**](/input-hub/manual/prompts/key-shapes.md): how the keys of a movement axis sit, like W over A S D.
* [**Prompt Style and Animate Prompts**](/input-hub/manual/prompts/prompt-style-and-animate-prompts.md): draw some prompts with another icon style, or make them play an animation, while an object is on.
* [**Hold Fill**](/input-hub/manual/prompts/hold-fill.md): a ring or a bar that fills while the player holds a Hold action.

## How a Prompt Picks Its Icon

For every action in a prompt, Input Hub:

1. Takes the binding that works on the device in use. On a gamepad, that's the binding with a gamepad button.
2. Picks the icon set for that device from the icon style of the game: the set made for that exact controller, or for its family. See [Icon Styles](/input-hub/manual/icon-styles.md).
3. Draws the icon of that key or button.

If the style has no icon for that key, the prompt writes the key's name instead, like **\[F13]**. If the action has no binding at all, it writes **Unbound**, which you can change in the [Settings](/input-hub/manual/settings.md#features).

## When Needed <a href="#when-needed" id="when-needed"></a>

This is the most important idea about prompts in Input Hub, so it's worth a moment.

By default, a prompt only shows **when needed**: while some script is reading one of its actions through Input Hub. You don't turn prompts on and off by hand. Your gameplay code already decides when an action matters, so the prompt simply follows it.

Here is a door that only reads **Interact** while the player is close:

```csharp
public class Door : MonoBehaviour
{
    public InputHubAction Interact;
    public Transform Player;
    public float Range = 2f;

    void Update()
    {
        bool near = Vector3.Distance(Player.position, transform.position) < Range;

        if (near && Interact.For(this).Down)
        {
            Open();
        }
    }
}
```

When the player walks up to the door, the script starts reading **Interact**, and the door's prompt fades in. When they walk away, it stops reading, and the prompt fades out. When the door is open and the script no longer asks, the prompt is gone for good. No extra code.

{% hint style="info" %}
`if (near && ...)` reads the action only while `near` is true, because C# stops at the first false. That is what makes the trick work: put the condition **before** the read.
{% endhint %}

### Which Script Is Reading?

With two doors in the scene, both reading **Interact**, you don't want both prompts to light up when the player is near only one of them. But with its **Reader** empty, a prompt lights up when **any** script reads its action, so that is exactly what happens.

Two things fix it, and they go together:

1. Each door reads with `Interact.For(this).Down`, or `InputHub.Down("Interact", this)`. `this` tells Input Hub that the read came from that door.
2. Each prompt has its own door in its **Reader** field. Now the prompt ignores every read that didn't come from its door.

| The prompt's Reader | The script reads with                        | The prompt shows                                               |
| ------------------- | -------------------------------------------- | -------------------------------------------------------------- |
| Empty               | `Interact.Down` or `Interact.For(this).Down` | When any script reads Interact.                                |
| The door            | `Interact.For(this).Down`                    | Only when the door reads Interact.                             |
| The door            | `Interact.Down`                              | Never, since Input Hub can't know the read came from the door. |

To keep a prompt on screen all the time, like a list of controls, set its **Show** to **Always**.

## Prompts in the Editor

Prompts draw in the editor too, outside Play Mode, so you can see them while you build your scenes. Use [Simulate](/input-hub/manual/devices/simulate.md) to see them as they look on any controller.

## Prompts in Local Co-op

A prompt inside an [Input Hub Player](/input-hub/manual/local-co-op.md) shows that player's device. Player 1 can see Xbox icons while player 2 sees PlayStation icons on the same screen.
