Drag and Drop GameObject to UI Window

I’m trying to recreate a weight based inventory. The inventory doesn’t care about slots or item counts, its entirely based on the weight of items. Ultima Online had a system like this and by dragging items within a bag it would change their Z order to render on top.

So my question is, how do I drag a game object into a canvas window. I assume when the mouse releases it will destroy the game object and create a image representation of that object and vice versa when I drag it out of the container to game space it will create a prefab.

Heres an example of the feature I’m trying to recreate:

Heres the basic code I have right now that just allows me to drag a game object around game space:

    void OnMouseDown()
    {
        mZCoord = Camera.main.WorldToScreenPoint(
        gameObject.transform.position).z;
        // Store offset = gameobject world pos - mouse world pos
        mOffset = gameObject.transform.position - GetMouseAsWorldPoint();
    }

    private Vector3 GetMouseAsWorldPoint()
    {
        // Pixel coordinates of mouse (x,y)
        Vector3 mousePoint = Input.mousePosition;
        // z coordinate of game object on screen
        mousePoint.z = mZCoord;
        // Convert it to world points
        return Camera.main.ScreenToWorldPoint(mousePoint);
    }

    void OnMouseDrag()
    {
        transform.position = GetMouseAsWorldPoint() + mOffset;
    }
}

What else do I need to get this off the ground?

Bump

You can hide world space mesh of dragged object and add another object into canvas wich tracks position of wolrd space object being dragged and follows it. If released within the bag, add UI item representation to the bag and delete world space object. If released outside the bag, then delete ui object

Have you found a solution for this? Do you want to recreate this in 2d or 3d?
I also try to implement a ultima online inventory system in 3d, but i believe that im to rookie for stuff like this.

I was looking to do this in a 2D setting, but I ultimately went a different route. I’d love to see an implementation of it, if you come up with a solution though.