pan camera left and right

hi, i am using this code for camera panning

if (Input.GetMouseButton(2)) { 
transform.rotation = cam.rotation; 
transform.Translate(Vector3.right * -Input.GetAxis("Mouse X") * moveSpeed); 
transform.Translate(transform.up * -Input.GetAxis("Mouse Y") * moveSpeed, Space.World); 

}

so if the middle button is pressed then i can pan up or down. now i want to make easy for people on notebooks to use the panning by moving mouse at the edge of the screen. it works for up and down because no matter how you rotate camera one can use position.y+=0.1 to do the panning. it gets harder for left and right because if you rotate the camera around the object it isnt relly panning any more if i use position.x+=0.1

so i would like to use Input.GetAxis if possible when mouse goes near edge of the screen for left and right panning. does this makes any sense?

thanks!

Vector3.right is always (1/0/0), use transform.right instead.

EDIT: for the same reason, note that transform.up is not necessarily (0/1/0) if your transform is tilted down-/upwards. So if you really want to pan parallel to the camera plane, transform.up is correct. If you just want to change the height and keep the X/Z position unchanged, use Vector3.up.