- Home /
How do I display the key from input manager in GUI text?
I have been working on a script that when I look at a game object tagged "Drawer" a GUI text object displays "Press 'e' to open drawer" but if the input manager has the "Open" axis key changed to any other key the GUI would be misleading. How can I set up the positive button for "Open" as a string variable? This is what I have now:
if(lookingAtHit.transform.gameObject.tag == "Drawer 2"){
centerText.guiText.text = "Press 'e' to open drawer.";
centerText.guiText.enabled = true;
bool x = Input.GetButton("Open");
if(lookingAtHit.transform.gameObject.tag == "Drawer 2"){
centerText.guiText.text = "Press '" + openButton + "' to open drawer.";
centerText.guiText.enabled = true;
bool x = Input.GetButton("Open");
The first code snippet is what I have. The second one is what I want to do but I don't know how to make the variable openButton.
Try adding .ToString to a keycode.
e.keyCode.ToString() == left$$anonymous$$ey
Answer by Lachee1 · Apr 14, 2014 at 10:18 PM
You cannot get the assigned key using Input Manager. You have to either:
A) buy a asset that lets you like cInput
or
B) make your own that uses Input.GetKey
Your answer
![](https://koobas.hobune.stream/wayback/20220613142719im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
key remaping menu 0 Answers
How to convert raw keycode to characters 1 Answer
How to access a String from another script in Javascript 0 Answers
Display text with unknown length? 1 Answer
Array strings/Loops problem 2 Answers