GetMouseButton problem

Hi ppl, unity noob here.

Anyway , i’m making a cube, and adding a script thtat looks something like this:

function OnMouseDrag () {

if (Input.GetMouseButton (0)) {

// stuff for left click

}

else if (Input.GetMouseButton (1)) {

// stuff for right click

}

}

But nothign happens when i try to drag it with the right mouse button, the left button works, isn’t this supposed to work??

And btw, does anyone know any tutorials somewhere about dragging objects around in space? Thanx.

function OnMouseDrag () {
if (Input.GetMouseButton (0)) {
// stuff for left click
GetComponent("Movescript").moveSelected();
}

if (Input.GetMouseButton (1)) {
// stuff for right click
}
}

You don’t need to else it…

And this is my moveSelected funtion in cs, I’m using List<> function elsewhere in my scripting so the mover is included in here: You can always adapt it to js…

void moveSelected()
	{
//check to make sure we have the object selected
		if(selectedNode != null)
		{
Raycast from the camera to the mouse position
			Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
//Test to see if the mouse is over the object
			RaycastHit hit ;
			if (Physics.Raycast(ray, out hit, 100.0f,1<<8))
			{
//If the mouse is over a gamobject then select that object
				GameObject go = selectedNode.go;
//Set our gameobject position variable to = the selected object's position and then set the pos of the object to be where the ray hitpoint is
				go.transform.position = SelectedNode.position;
				SelectedNode.position = hit.point;
			}		
		}
	}

Hmmm, still doesn’t work.

I tried to use

if (Input.GetButton(“Fire2”)){}

but that doesnt work either, i tried to print something withing the brackets, it doesnt reaach it at all…

Can you post this code?