GetBindingDisplayString() returns an empty string for certain bindings?

I’m trying to make a system where I can display all of the buttons from an InputActionMap on the screen

string controlName = control.GetBindingDisplayString();
Debug.Log($"{control.name} {controlName}"); 
if (control.bindings[0].isComposite) controlName = control.bindings[0].name;
        
buttonHint.GetComponent<TextMeshProUGUI>().text = $"<b>{control.name}</b> - {controlName}";

“control” is of type InputAction. And, well:


You can see here that “Engage” and “Enter Command-Mode” will return an empty string

Any clues as to why?

EDIT: This code seems to give me the results I was looking for:

string controlName = control.bindings.FirstOrDefault().ToDisplayString();
if (control.bindings.FirstOrDefault().isComposite) controlName = control.bindings.FirstOrDefault().name;
buttonHint.GetComponent<TextMeshProUGUI>().text = $"<b>{control.name}</b> - {controlName}";

That being said, what described in the post may still be a bug and if that is the case I hope it finds the devs’ attention.

1 Like

So, I discovered that you need to tick an option in “Use in control scheme”. This also fixes the action not being able to reset binding.

image

F keys (F1, F2, etc.) also seem to return an invalid character:
180084-screenshot-2021-04-30-at-192539.png