- Home /
Input.GetMouseButtonDown(1): do the primary and secondary buttons work differently?
Input.GetMouseButtonDown(0) works for me as intended, I click and get one true until I release and click again.
However the secondary button (left click) doesn't seem to be working the same way. Every time I try it, it is true when the click happens but also when the click is released (sometimes there is an extra click registered too???). It sounds crazy, but is the primary mouse button handled differently than the secondary? I have the most basic script ever, and I have confirmed that there is only one of these scripts in the scene (it works fine if I change to the primary button):
void Update()
{
if (Input.GetMouseButtonDown(1))
{
Debug.Log("Click: " + Time.time);
}
}
I clicked twice in this test:
Once at 2.6... seconds and released at 3.2 seconds
I have no idea where the 2.7 second click event came from
The second click was the 4.5... second click and released at 5.2...
It seems pretty consistent with the left click (secondary click) to always fire the event when I release. Is there some kind of behavior settings for what to do when different buttons are clicked?
Answer by Hunika124 · Oct 30, 2021 at 10:30 PM
Button 0 is the left click, the 1 is the right, 2 middle
Wow, thank you for that... but I totally knew that. When I getMouseButtonDown(0) it works with the left click yes, but it works correctly only registering 1 event (being true once), but when I do the getMouseButtonDown(1) for the right click, I get at least 2 events fired (the if statement is true when I click down and when I release). Now, can you or anyone answer why these 2 behave differently.
Your answer
Follow this Question
Related Questions
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
What's the entry name for mouse buttons in InputManager? 2 Answers
New Input axis with Numpad Keys 2 Answers
New unity input system problems 0 Answers
GuiTexture as crosshair as scroll over to activate things 1 Answer