drag an object

when iam attaching below code to cube/sphere it getting drag, but when iam attaching to 3d object its not getting drag, i dont know the reason behind this?
script

using UnityEngine;

using System.Collections;

public class GizmosController : MonoBehaviour {

private Vector3 screenPoint;

private Vector3 offset;

public GameObject gameObject;
 
void OnMouseDown()

{

    screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position);

		Screen.showCursor = false;
 
    offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));


}
 
void OnMouseDrag()

{

    Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);


 
Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
transform.position = curPosition;

	
			
 
}
	void OnMouseUp()

	{

Screen.showCursor = true;

	}
 
}

I see one problem. ScreenToWorldPoint() takes the distance in front of the camera. It is not a world position. So your use of screenPoint.z for this value is problematic. If the camera is looking down the ā€˜Z’ axis, you could do something like:

float dist = Mathf.Abs(transform.position.z - Camera.main.transform.position.z);

And use this distance in your ScreenToWorldPoint() call.