Detect Right Click on GUI Buttons

Is it possible to easily detect weather the player has left or right clicked an OnGUI function Button.

I Know that placing a simple IF before the button will supply a true false for if it is left clicked, however how does one do this for right clicks.

Thanks guys,

You can look at the Event. Event.button is an int that indicates which button was pressed.

#pragma strict

function OnGUI() {
	var e = Event.current;
	if (e.type == EventType.MouseUp && e.button == 1)
		Debug.Log("Right mouse button lifted");

if(GUI.Button(new rect(0,0,0,0), “Button”)) {
if(Input.GetMouseButtonUp(0)) {
Debug.Log(“left click”);
else if(Input.GetMouseButtonUp(1)) {
Debug.Log(“right click”);


I noticed your post, hope your still checking up on it. This is something I tossed together that works for me. And I also hope this helps you and whomever is coming across this problem.