- Home /
OnMouseUp does not work
Hi
I wrote a code:
void OnMouseUp()
{
if(Input.GetKey(KeyCode.Mouse2)) rotateByMouse=!rotateByMouse;
}
I want to switch bool rotateByMouse by middle mouse button-yet this code suprisingly does not work?Anyone knows why?I've checked doc about MonoBehaviour.OnMouseUp(),but there is no mentioning it works only with left mouse button...If so,I have absolutly no idea what's wrong with my code :/
Answer by Eric5h5 · Jul 10, 2011 at 05:54 PM
OnMouseUp is only for the left mouse button. You can use Input.GetMouseButtonUp(2) in OnMouseOver instead.
Thanks Eric,it's nice to know.But I think such important information shoud be mentioned in documentation-who is responsible for that?He/she shoud be informed that On$$anonymous$$ouseUp doc is inaccurate
@$$anonymous$$asterBLB: The docs do say "On$$anonymous$$ouseUp is called when the user has released the mouse button". "The" mouse button means just one, which would indicate the default (left) button. It could be made more obvious though. You can use the bug reporter app to report documentation bugs.
I sent a report.
Eric,I see you're a wise and experienced in Unity guy,could you look at my other issue:
http://answers.unity3d.com/questions/141300/convert-vector-in-world-to-mesh.html
Your answer
![](https://koobas.hobune.stream/wayback/20220612140424im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to disable click to move on interface elements ? 0 Answers
Unity doesn't recognize mouse clicks, C# 1 Answer
Change Camera on (Right) Mouse Click 1 Answer
Problem with OnMouseDown 1 Answer
Change Pickup key 1 Answer