Mouse drag function on stretching object script

So i am trying to create a script which will allow the player to click on a game object and drag out to stretch it or drag in to make it smaller. The object in question is a circle.

The problem I think I am having is that I am struggling to find the distance between the current mouse position and the initial start point of the dragging. In the inspector, they are showing up as the same. Can anyone advise me on how to fix my script?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class StretchShape : MonoBehaviour
{
    public bool dragging = false;
    public Vector3 dragStartPoint;
    public Vector3 currentMousePosition;
    public Vector3 temp;
    public float amountDragged = 0.0f;
 

    private void OnMouseDown()
    {
        dragStartPoint = (Input.mousePosition);
    }
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            //If not dragging:
            if (dragging == false)

            {   //Run raycast on mouse position.
                Vector2 rayPos = new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
                RaycastHit2D hit = Physics2D.Raycast(rayPos, Vector2.zero, 0f);

                //If raycast hit something:
                if (hit)
                {
                    //If raycast hit object:
                    if (hit.collider != null)
                    //Store current mouse position
                    {
                        currentMousePosition = (Input.mousePosition);
                        //Set dragging = true
                        dragging = true;
                    }

                }
            }


            //Else if we are dragging:
            else if (dragging == true)
            //Calculate distance to drag start point
            {

                amountDragged = Vector3.Distance(currentMousePosition, dragStartPoint);
                //Scale accordingly (transform)
                temp = transform.localScale;
                temp.x += amountDragged;
                temp.y += amountDragged;

            }

        }
        else
        // reset dragging
        {
            dragging = false;
        }
         
    }

}

There are a few logical mishaps here and that is why it doesn’t work:

Line 36 - If you store the current position only when your mouse button goes down it will only happen once. Update this value when the mouse is being dragged instead.

Line 46 - That entire conditional statement should be outside since mouse button down only triggers once.

The fixed Update method:

private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (dragging == false)

            {   //Run raycast on mouse position.
                Vector2 rayPos = new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
                RaycastHit2D hit = Physics2D.Raycast(rayPos, Vector2.zero, 0f);

                if (hit)
                {
                    // If raycast hit something, you should instead start the dragging state
                    if (hit.collider != null)
                    {
                        dragging = true;
                    }

                }
            }
        }
        else if(Input.GetMouseButtonUp(0))
        {
            dragging = false;
        }

        //Calculate distance to drag start point
        if (dragging == true)
        {
            currentMousePosition = (Input.mousePosition);
            amountDragged = Vector3.Distance(currentMousePosition, dragStartPoint);

            //Scale accordingly (transform)
            temp = transform.localScale;
            temp.x += amountDragged;
            temp.y += amountDragged;

            transform.localScale = temp;
        }
    }

Edit: Just an observation, try converting mouse position to world position and set the scale as the distance. Much more manageable that way.

i am having drag issue with my player as skater wearing skates. kindly tell me how can i do it for 3d?

void Update()
{
if (Input.GetMouseButtonDown(0))
{
prevMousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10);
prevMousePos = Camera.main.ScreenToViewportPoint(prevMousePos);
offset = prevoffset;
print("Mouse Down : "+offset);
prevMousePos = prevMousePos - lastpos;
}
if (Input.GetMouseButton(0))
{
mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10);
mousePos = Camera.main.ScreenToViewportPoint(mousePos);
offset = (mousePos.x - prevMousePos.x) * 5;

// if (mousePos.x != 0)
//{
// offset = (mousePos.x - prevoffset) * 5f;
//}
print("Mouse Pressed : " + offset);
}
if (Input.GetMouseButtonUp(0))
{
lastpos= Camera.main.ScreenToViewportPoint(mousePos);
mouseclickno = 0;
prevoffset = offset;
print("Mouse Up : " + offset);
}
if (Input.GetMouseButtonUp(0))
{
if (prevMousePos.x == 5)
{
}
}
this.anim.Play("STRECH", 0, offset);
if (reached && i == 0)
{
cam.rotation = Quaternion.Slerp(cam.rotation, rot, 0.8f * Time.deltaTime);
}
if (skates.springjump)
{
anim.SetLayerWeight(2, 0.8f);
anim.SetTrigger("JUMP");
print("Jumpee");
}
if (skates.skatejump)
{
anim.SetLayerWeight(2, 0.8f);
anim.SetTrigger("JUMP");
print("JUMP");
}
}

@Wezai
@Joe-Bubaganoosh