- Home /
How to get Input Button name?
How can I access the button name that is selected for the current Input?
Lets say that I have:
Input
Name:Action
Positive Button: A
How can I access the A? For something like:
"Press the (button asigned by the user, in this case A) to continue"
Instead of
"Press the action button to continue"
Unity's Input $$anonymous$$anager doesn't support runtime re-mapping. So you'll have to keep track of the buttons assigned by the user in a custom class. Here's one example how: http://wulverblade.com/dev-blog-wrangling-unitys-input/
Thanks, I guess that I will need to create my own Input $$anonymous$$anager then.
Answer by RevolutionNow · Sep 07, 2014 at 11:39 AM
First you need to go to the input manager (Edit>ProjectSettings>Input). You Name it Action(or whatever you want)and you choose the positive button be A.
If (Input.GetButton("Action")){
Continue}
This doesn't answer the question, which is how to know at runtime the "Positive Button" that is assigned to an axis, knowing only its name.
Answer by vfxjex · Dec 26, 2015 at 07:20 AM
//This will get the name of the button that was pressed.
string name = EventSystem.current.currentSelectedGameObject.name;
Your answer
Follow this Question
Related Questions
Switch Between Touch And Mouse Controls 0 Answers
How to detect input being hold in new Input System 2 Answers
Disable Image Effects on Input 0 Answers
How can I get user-defined inputs? 1 Answer
Unbinding in game settings 1 Answer