I would like to show a graphical UI hint for actions.
Let’s call the action “Fire” and I can trigger it with “E” on the Keyboard or with “A” on my XBox Controller. I want to show a sprite showing the E key when the Keyboard is used and another showing a round A icon for the Controller (and so forth).
Let’s say I have a mapping from the most fine grained binding path (so NOT /something but /something) to a UI sprite.
Is there a way to receive a PlayerInput object, read it’s active device and get a list of all the bindings of THAT specific device that will trigger the actions of my action asset? (A bit like the control scheme filtering that can be applied in the InputActionAsset UI, but device specific)
In my UI component I could then set an Action Reference, resolve that to a binding path and that binding path to a sprite.
Is this currently possible?
Cheers!
I do want to use the binding path strings so a custom rebind by the player will also update the displayed sprites.
After some reading I found that this is probably related to this question:
It’s possible but currently requires a lot of custom scripting and a good deal of knowledge that shouldn’t be necessary.
Given how many users have run into problems here, we’re currently working on a major quality-of-life improvement for rebinding including a sample that also does custom icons. The changes are in their final stages and are expected to be part of the next package.
For anyone else looking for this, you can install the “Rebinding UI” sample from the package manager window when you select the “Input System” package. In that sample you will find a GamepadIconsExample script which shows how to hook into the callbacks of the RebindActionUI component and override the default textual display with custom icons.
Thank you for the example. Did help with finding the method to retrieve the icons names.
Can you updated it to include composite examples? The sample does not work with ButtonWithOneModifier. Instead of showing the icons, it just shows the text.
Does unity provide out of the box classes to “convert” the input action bindings into wrapper classes to help with icons / rebinding for composites?
I’m replicating unity classes to handle the above and I feel that there is a better way to do it which is also future proof.
Hi, if anyone is looking to display action bindings in UI, there is an asset I have made which will help you. It makes use of the style tag of textmesh pro to display bindings. So displaying an action is as easy as to type <style=NameOfActionMap/NameOfAction> into a textmesh pro field. The displayed bindings will also update automatically when you switch to a controller and back to the keyboard/mouse, no additional code required.