Hand tool on a 2D plane

Hello, I'm trying to do a simple 2D "hand tool". I got it working but I accidentally deleted something I thought was obsolete. As it turns out, my first try was a stroke of luck, since I haven't been able to make it work again.

I experience a bug where the camera flickers when i try to drag. I'm sure I'm not the first person to do a drag script (maybe the biggest n00b tho), but i cannot find any other documentation on this. Any input would be appreciated.

var camCurrent : Vector3;   //static camera position
var pressedPosDif : Vector3; // difference between pressed and moved
var pressedPos: Vector3; //starting coordinates for button hold
var pressed:boolean = false; //is the button held?

function Start(){


function Update () {
    if (Input.GetMouseButtonDown(0)) {
        pressedPos = (Camera.main.ScreenToWorldPoint(Input.mousePosition));
        pressed = true;

function mouseCheck () {
    while (pressed) {
    if (Input.GetMouseButtonUp(0)) {
            pressed = false;

This seems like more work than you need.

Why not do something like:

MouseTranslate.js (Attached to the camera)

var scale : float = 0.2f
function Update() {
    if(Input.GetMouseButton(0)) {
        transform.position -= transform.right * Input.GetAxis("Mouse X") * scale;
        transform.position -= transform.up * Input.GetAxis("Mouse Y") * scale;

For more precise movement, you could do some screen point converson:

MouseDragPosition.js (Attached to the camera)

var planeDistance : float = 10.0f;
private var dragPoint : Vector3 = Vector3.zero;
function Update() {
    var screenPoint : Vector3 = camera.ScreenToWorldPoint(Vector3(
    if(Input.GetMouseButtonDown(0)) dragPoint = screenPoint;
    else if(Input.GetMouseButton(0)) transform.position += dragPoint-screenPoint;