La question est hors-sujet ou n'est pas pertinente
Mouse button up and down
Hi everybody ! I'm just want to know what's the difference between : "Input.GetMouseButtonDown(0)" and "Input.GetMouseButtonUp(0)"
Some one can help me ? Thank you, xyHeat
Answer by HarshadK · Jun 01, 2016 at 11:46 AM
Read the documentation for Input.GetMouseButtonDown and Input.GetMouseButtonUp.
From the same documentation:
Input.GetMouseButtonDown: Returns true during the frame the user pressed the given mouse button. You need to call this function from the Update function, since the state gets reset each frame. It will not return true until the user has released the mouse button and pressed it again. button values are 0 for left button, 1 for right button, 2 for the middle button.
Input.GetMouseButtonUp: Returns true during the frame the user releases the given mouse button. You need to call this function from the Update function, since the state gets reset each frame. It will not return true until the user has pressed the mouse button and released it again. button values are 0 for left button, 1 for right button, 2 for the middle button.
The 0 passed as argument to these methods indicate the left mouse button.
Thank you for this answer ! I'm sorry, i didn't realize that my question was so stupid...
Answer by TheCheatsrichter · Jun 01, 2016 at 12:13 PM
Just imagen the mouse button itself.
When you press it down Input.GetMouseButtonDown() will return true. The moment you release it (button goes up) Input.GetMouseButtonUp() will return true.
Thank you, now i this about it, i realise how much this question was stupid...
Answer by Mmmpies · Jun 01, 2016 at 11:25 AM
Really?!
OK well one is used for drag DOWN and the other for click UP. Think about it when you drag something the mouse button will be down all the time and to release you let go with an up event. Any engine has to include all the states for a device to work properly.
one is used for drag DOWN
Actually this is done via Input.Get$$anonymous$$ouseButton
which will be called for each frame the mouse button is held down.
Really I was more explaining why you need to have both down and up as the question was so basic. Possibly they're trolling but maybe not, to a new user it might not be obvious they do different things.
There are no stupid questions but there some stupid people who get a laugh out of posting very simple questions to waste peoples time.
Clearly, from your response, that isn't what you were doing so don't worry about it - like I said to @Harshad$$anonymous$$ it's quite possible for someone new to Unity not to see the difference immediately as a mouse click is a mouse click regardless of down or up.
Follow this Question
Related Questions
getting maximum x and y values of mouse position 1 Answer
Subnautica Type swimming 2 Answers