OnMouseUp does not work


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 :confused:

OnMouseUp is only for the left mouse button. You can use Input.GetMouseButtonUp(2) in OnMouseOver instead.