- Home /
keybinding/keycodes
I am using c# and am stuck working on the keybindings. As of now I am using:
void OnGUI (){
Event e = Event.current;
if(e.isKey)
{
keyboard.keys[num] = e.keyCode;
}
keys is a keycode array and keyboard is another script that has that array. For the controls them selves I want to be able to use keys[1] as the keycode but am not sure how to go about doing that. I thought that this would work but it doesn't:
if(Input.GetButton(keys[1]))
any ideas on what I need to do?
Answer by whydoidoit · Jan 09, 2013 at 06:19 AM
As it's a key you need to use Input.GetKey(keys[1]) - I'd suggest using an enum so you dont have to remember which integer relates to which actions too - just to avoid hard to spot bugs later.
Wow, I can't believe I overlooked that. Thanks you so very much.
Your answer
Follow this Question
Related Questions
Converting string of a key into KeyCode 2 Answers
C# String Array Has Missing or Incorrect Keycode Strings 2 Answers
Another KeyCode problem... 2 Answers
How to convert raw keycode to characters 1 Answer
Font issue in unity 3d 3 Answers