dragging 2d objects

hi folks,

i want to drag 2d objects, but not by clicking on it, i want to make it drag by clicking any point in the game screen, is that possible? Can you please help me guys for that, i wrote this code but its not working:

using UnityEngine;
using System.Collections;

public class drag2d : MonoBehaviour {
float x;
float y;

// Update is called once per frame
void Update(){
x = Input.mousePosition.x;
y = Input.mousePosition.y;
}

void OnMouseDrag(){
transform.position = Camera.main.ScreenToWorldPoint(new Vector3(x,y,10.0f));
}
}

OnMouseDrag only works for things with colliders, and if only for the thing you click on.

If you want to support full screen dragging, you’d either need a full-screen game object wth collider and a script, or you’d need to put a script on the game object you want to drag and then just read the Input.mousePosition/etc in the Update function and act on its information.