Input hints are little prompts in game that display the button, key or action that the player needs to perform to execute a certain action.
Press [A] to Jump
Unity's new Input and Localization systems are perfect for displaying dynamic Input Hints, changing depending on the actual bindings set up in the Input Actions. TextMesh Pro is used for displaying sprites inline in text strings. All that it needs is a little bit of plumbing, and this package is that plumbing!
You will need actual icons to display in the text. I can recommend the excellent PC & Consoles Controller Buttons Icons Pack. This package is based around the way they set up sprites.
- Install the package from the git URL
- I'm assuming you already have Input Actions and the Localization System set up.
- In Unity, go to
Assets/Create/Noio/Input Hints Config
- Follow instructions on the Input Hints Config asset.
- Check out
DeviceDetectorSample.cs
If the button to automatically hook up the Localization Settings "Smart Format Source" does not work, this is the manual setup required:
- Click to Assets > Create > Localization > Variables Group
- In the newly created Variables Group Asset, add a variable, name it "input" and link the Input Hints Config.
- Go into the Localization Settings Asset and open up String Database > Smart Format > Sources > Persistent Variables Source
- Add the Variables Group Asset that you created in Step 1:
See below for a sample setup that uses the actions defined in Unity's Default Input Action Map (Look, Move, Fire), and the controller icons linked above.
Makes sure to select at least one "Use in control scheme" for each binding in the Input Actions.
Try using LocalizeStringEvent
instead of GameObjectLocalizer
. It seems that the latter component sometimes
does not respond when a localization variable is changed.