- Home /
How can I get text in a canvas to display the name of a key that is chosen by the player in the input panel of the launcher?
Pretty simple question, basically, what I want is something on the HUD to tell the player what key to press to activate a certain ability.
This:
weaponKey.GetComponent(UI.Text).text = /*Button from input panel*/;
Thanks for your help, guys. c:
Answer by zach-r-d · Jul 14, 2015 at 08:02 AM
Unfortunately, there is no official support for accessing the Input Manager from scripting, though it's been frequently requested for a very long time. Based on the roadmap, it seems likely that Unity is waiting until they can completely overhaul the input system.
There is a hacky, unofficial way to access and manipulate the data manually in the editor, so it is possible to add some sort of scene or build postprocess hook to update public string fields of desired scripts to have the correct button names. However, this is pretty overkill, and would not work if the user changed the input settings in the launcher anyway.
Well, damn. I guess I'll just have to resort to labeling them 1 through 4. Thanks for your answer. :P
Your answer
Follow this Question
Related Questions
Use Canvas Buttons as Input Axis 1 Answer
IPointerEnterHandler doesn't work when object switches parent 1 Answer
world canvases z fighting or rendering in the order when camera moves around 0 Answers
Particle System not showing over "Screen Space - Overlay" UI Canvas 0 Answers
UI Fading in flicker 5.5 1 Answer