How to show bindings in button text?

Hello everyone,

I was looking for a way to read binding paths in script so I can show them as string in a button text (later I will try to make it controls rebinding menu). Sorry if what I say doesn’t make sense, .I am a beginner in game development still trying to learn lots of things. I looked through the documentation for new input system but couldn’t quite understand :slight_smile: Thanks.

I too am looking for a way to do this.

Stay tuned. We should have an improvement here shortly. Many users have struggled with this and rather than trying to explain at length how to do this with the current API and how to avoid the many pitfalls, I figured it’s a hole that better be plugged now by just providing a simple wrapper API that requires little explanation.

2 Likes

In case somebody is looking for the mentioned improvement. It is linked here: Show UI Icons for Actions - Unity Engine - Unity Discussions

Basically a Sample on the “Input System” package in Unity. You can find it in the Package Manager if you install the Input System and open the little “Samples” drop down there. You want to check out the “Rebinding UI” sample.

1 Like

Thank you.

I have created an asset (available in the asset store) which provides button prefabs for easy rebinding behaviour: https://forum.unity.com/threads/rel…meshpro-easily-display-your-bindings.1253292/

The tool also allows you to display input bindings in textmesh pro texts by using the TMPro style tag. You can display a sprite for an action of an action map by typing <style=NameOfActionMap/NameOfAction> into a text field. This way you can have your bindings displayed in the same line as other text and don’t have to mess around with positioning of text and sprites in your UI. Whenever the PlayerInput component detects a change to the active device (via the controls changed event), the displayed sprites will get updated to show sprites for keyboard or gamepads (XBox, PS or NS Pro)