Drag and Drop Scripts?

Has anyone ever created a drag and drop script for unity? Or maybe even a demo? If so, can you show me a link? Thanks.

EDIT: Or if not, how to make one.

Here is what I think the process would be like:

  1. Set up a script to tell it when your dragging and dropping
  2. Set the object hologram to follow your mouse position
  3. Instantiate at release point
  4. Add delete button and move options

I can do #3 and most of #4 but not sure about 1 2…

Yeah unity has a drag and drop script its one of the standard assets.

The Drag Rigidbody script (in Unity’s standard assets as aiursrage2k said) will probably help if you are dragging objects in the scene but if you want to do this in GUI then check out this thread for an example.

i have used this drag and drop script in my game just add a ridged body to it and a collider

//Script to drag an object in world space using the mouse

 

 

var screenSpace;

var offset;

 

function OnMouseDown(){

    //translate the cubes position from the world to Screen Point

    screenSpace = Camera.main.WorldToScreenPoint(transform.position);

     

    //calculate any difference between the cubes world position and the mouses Screen position converted to a world point  

    offset = transform.position - Camera.main.ScreenToWorldPoint(Vector3(Input.mousePosition.x,Input.mousePosition.y, screenSpace.z));

    

}

 

/*

OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse.

OnMouseDrag is called every frame while the mouse is down.

*/

 

function OnMouseDrag () {

 

    //keep track of the mouse position

    var curScreenSpace = Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z);     

 

    //convert the screen mouse position to world point and adjust with offset

    var curPosition = Camera.main.ScreenToWorldPoint(curScreenSpace) + offset;

 

    //update the position of the object in the world

    transform.position = curPosition;

}

There is another drag drop script on the unity wiki. A bit more precise than the regular one.

Halo Sicga .
Will you please say where to find unity wiki ?
Thanks.