Drag and drop a handle onto an object.

So I want to make a handle in 3D space when you select an object with a script on it. Then I want you to be able to click and drag that handle to another object and drop it, and if that other object has a certain script, then it connects that handle to the object you drop the handle on.

What I can’t figure out is, when dragging in editor 3D view, how can you get a reference to the object that is currently underneath the mouse pointer?

From this question, I would suggest doing it like this:

var ray=Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if(Physics.Raycast(ray,hit,100))
{
    var hitObject=hit.collider.gameObject;
}

You can change the ray length (the 100 number) if your camera is a long way away from the objects you’re selecting.

In future I recommend you do a Google search first. I searched “unity find object under mouse” to find that answer. The first result had the answer.