- Home /
Differnce between KeyCode.Mouse0 and GetMouseButton(0)
Is there any difference if I use
if (Input.GetKey(KeyCodes.Mouse0))
{
//...
}
or
if (Input.GetMouseButton(0))
{
//...
}
Are there any differences? (perfocmance, etc.)
No, don't think there are any differences. I've used Unity for 5 years and never knew there was a Get$$anonymous$$ey()
that gave mouse events. I'd think that was well off the beaten path, so use Get$$anonymous$$ouseButton()
like everyone else. ;-) Then again, both will probably end up in the same Unity runtime code.
I know this is an old question, but I'm still interested in a more detailed answer. The reason is that I find using an int constant as parameter really repulsive, so would prefer the enum version, if the result is the same.
So for example:
Input.Get$$anonymous$$ouseButton(0); // parameter could be 1 or 2 as well
// vs.
Input.Get$$anonymous$$ey($$anonymous$$eyCode.$$anonymous$$ouse0); // parameter could be $$anonymous$$ouse1 or $$anonymous$$ouse2 as well
Would this be the same?
Your answer
Follow this Question
Related Questions
How do I get a GUI Texture Button to act as a Input Key such as a T button on a key bored or so? 1 Answer
How can I synchronize the cooldown on two separate scripts? 2 Answers
Input.GetKeyDown doesn't work first button press 1 Answer
Input.GetKey not working 1 Answer
How to unlink Arrow Keys Input with Keypad 2468 buttons 2 Answers