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.
Answer by sirmarcomoro · Apr 30, 2021 at 06:27 PM
F keys (F1, F2, etc.) also seem to return an invalid character:
Your answer
Follow this Question
Related Questions
Unable to assign devices to PlayerInput whit Instantiate() 1 Answer
Making an object move non stop after button input? 1 Answer
InputSystem - Touch.delta ping-ponging 1 Answer
Help with improving, dynamisation of Input code 1 Answer
how to make an animation to play when a int has a certain value, and pressing space key? 0 Answers