- Home /
Processing keyboard button input like in GUI
Hello,
I have a simple UI where when you press a button on keyboard 'Enter' or gamepad on one menu, another submenu appears. The problem is when I press the button, the new submenu appears and immediately process the input as if 'Enter' was pressed again.
if(Input.GetKey(KeyCode.JoystickButton0)) {
activeButton.SendMessage("PressButton", SendMessageOptions.DontRequireReceiver);
}
I need to find a way where when the new menu appear, I have to leave the button and press again to go into the new submenu entry.
Any help is greatly appreciated, thanks for advance.
Answer by ThomLaurent · Sep 29, 2014 at 12:28 AM
The problem you describe is due to the Input.GetKey() method you use, did you try to use Input.GetKeyDown or Input.GetKeyUp instead ?
It is said that Input.GetKey as the effect of an "auto fire" (see Unity's documentation)
Your answer
Follow this Question
Related Questions
Trying to Highlight text in order to copy and paste, but do not want the text to be editable. 1 Answer
Changing the Standalone Input Manager variables 2 Answers
Emulate RightArrow GUI Event 0 Answers
Why won't my object activate? 0 Answers
Rewriting a bullet count GUI to run more efficiently 1 Answer