Drag and drop sprites across transparent window overlay

I made the game into a transparent window overlay using Windows API. I added a sprite (which is the default white square) and want to add functionality so that when I click and drag it across the screen using LMB, I can drag the sprite with me and release so that it just falls back to the bottom of the screen. The basic falling physics are done, I just need to code the drag-and-drop part. I’ve tried a typical solution but it doesn’t seem to work; the cursor just interacts with whatever is below the sprite and doesn’t register at all. Any suggestions are appreciated.

using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;
using UnityEngine;

public class MouseInteractions : MonoBehaviour
{
    private Vector3 offset;
    private bool dragging;

    void Update()
    {
        if (dragging)
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            Vector3 newPosition = ray.GetPoint(10) + offset;
            transform.position = newPosition;
        }
    }

    void OnGUI()
    {
        Event e = Event.current;
        Vector2 mousePos = e.mousePosition;
        if (e.type == EventType.MouseDown && e.button == 0)
        {
            Ray ray = Camera.main.ScreenPointToRay(mousePos);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit) && hit.transform == transform)
            {
                GetComponent<Rigidbody>().isKinematic = true;
                offset = transform.position - hit.point;
                dragging = true;
            }
        }
        else if (e.type == EventType.MouseUp && e.button == 0)
        {
            dragging = false;
            GetComponent<Rigidbody>().isKinematic = false;
        }
    }
}