- Home /
Input - Checking if Input Key/Button Exists
Hey,
How do I go about doing that? Is it possible?
Every time I use GetKey() or GetButton() it returns an error that the button or key doesn't exist. In an environment where you can set a variety of different keys (along with some that might not even be set up yet) how do I first check if a button/key exists so that I can then set an input button/key that DOES for sure?
In case the answer is easily found, i'll post my lmgtfy link here:P
At least I tried!
It might be possible, but I'm confused how this is co$$anonymous$$g about: if you're calling Get$$anonymous$$ey with $$anonymous$$eyCodes, you'll never get a key that doesn't exist. If you're calling GetButton, you should probably only check for buttons which you've defined in the Input $$anonymous$$anager config.
So checking if a specific Button isn't possible? That stinks...
The buttons are define by you. They are not system buttons that are tied to anything specific. There are some defaults buttons provided for your convenience that you can edit or delete using the Input $$anonymous$$anager.
you can set a variety of different keys
You can certainly write your own code that allows a user to maps specific keys to specific functionality at runtime. Unity does not provide this for you. With Unity, you can define keys at edit time in the Input manager.
Please read this:
http://docs.unity3d.com/Documentation/$$anonymous$$anual/Input.html
And watch this:
Answer by chanye · Nov 01, 2013 at 03:56 AM
I think you should check the button or keys ,if they were not exist ,when you use this ,then come to the nullpointerror