How can i drag 2D sprites in unity 2020?

I’m creating a simple simulation where dragging and dropping is the main method of interacting with the user. My problem is that while UI elements are easily dragged around the scene, My 2D sprites cannot be dragged, even though the event shoots up on the console with Debug.Log. Here is the code I’m using to drag the sprites:

private Vector3 screenPoint;
private Vector3 offset;

void OnMouseDown()
{
    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;
    Debug.Log("dragged");
}

You need to consider the camera position in order to get the offset.
Here is the rectified code:

private Vector3 offset;
void OnMouseDown()
{

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

void OnMouseDrag()
{
    Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, -Camera.main.transform.position.z);
    Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
    transform.position = curPosition;
}