OnMouseUp() only works the first time

Hi,

I’ve spheres that have implemented Drag N’ Drop function.

Well, if I move any of this spheres, all methods are invoked: OnMouseDown(), OnMouseDrag(), and OnMouseUp(). There is no problem… The spheres are moving correctly, but only the first time that I drag the sphere.

The second time that I drag any sphere, the method OnMouseUp() is not invoked… I’m going crazy, I don’t know why it occurs.

The code:

void OnMouseDown(){
      initialPos=transform.position;
      dist=Camera.main.WorldToScreenPoint(transform.position);
      posX=Input.mousePosition.x-dist.x;
      posY=Input.mousePosition.y-dist.y;
}

void OnMouseDrag(){
        Vector2 curPos =
            new Vector2(Input.mousePosition.x - posX, Input.mousePosition.y - posY);
        worldPos = Camera.main.ScreenToWorldPoint(curPos);
        transform.position = worldPos;
        Debug.Log (transform.position);
    }

    void OnMouseUp(){
        Debug.Log ("Size: "+Level1Positions.Length);
    }

Any idea?

That script is attached to a prefab, that is instantiated through another script.

The first time, the debug.Log is shown, but only this time.

Thanks!

Does the Debug.Log in OnMouseDrag() still show after the first OnMouseUp()? It sure sounds weird to me.