How to move cubes with finger

I'm trying to figure out a way to move cubes with my hand sort of like I select a cube, drag my finger across the screen with the cube still at then edge of my finder and when I lift off the cube stays in the screen position its been moved to.

I cant seem to figure out how to implement this?

I tried coding it myself with:

var target1: Transform;
var target2: Transform;
var speed:float = 0.1;

function Update () {
    if (Input.GetMouseButton(0)) {
        var ray: Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        var hit: RaycastHit;

        if (Physics.Raycast(ray, hit)) {
            if (hit.transform == target1) {
                print("Hit target 1");

        // Get movement of the finger since last frame
        var touchDeltaPosition:Vector2 = iPhoneInput.GetTouch(0).deltaPosition;

        // Move object across XY plane
        transform.Translate (touchDeltaPosition.x * speed, touchDeltaPosition.y * speed, 0);

            } else if (hit.transform == target2) {
                print("Hit target 2");
            }
        } else {
            print("Hit nothing");
        }
    }
}

But that didnt seem to work at all.

Any thoughts on this?

Your code seems almost identical to a question I answered earlier.

So here: http://answers.unity3d.com/questions/12872/using-touch-doesnt-get-the-correct-vector/12874#12874

The FingerGestures asset store package has a sample that does exactly what you’re describing. Check it out here: http://forum.unity3d.com/threads/95983-FingerGestures-Robust-input-gestures-at-your-fingertips!