@CocoCode

Want to learn how to create advanced Inventory UI?
👉 Check out my newest course, Master Unity UI ➡ https://bit.ly/cc-unity-ui-114
It’s packed with everything you need to create awesome UI ✨🎨

@standardLit

Just from the first few second I watch your video, I already know your tutorial was extraordinary. Then I got to 04:50 mark. I was wrong, it was more than that! This is the type of tutorial that everyone hoped to see when they need one.

@bertiedev6478

For anyone that wants the items to swap slots when dropping on a full slot here is how.

public void OnDrop(PointerEventData eventData)
    {
        if(transform.childCount == 0)
        {
            GameObject dropped = eventData.pointerDrag;
            DraggableItem draggableItem = dropped.GetComponent<DraggableItem>();
            draggableItem.parentAfterDrag = transform;
        }
        else
        {
            GameObject dropped = eventData.pointerDrag;
            DraggableItem draggableItem = dropped.GetComponent<DraggableItem>();

            GameObject current = transform.GetChild(0).gameObject;
            DraggableItem currentDraggable = current.GetComponent<DraggableItem>();

            currentDraggable.transform.SetParent(draggableItem.parentAfterDrag);
            draggableItem.parentAfterDrag = transform;
        }
    }

@esmeestevens4018

This is awesome, exactly what I needed for my school project! Easy to follow and understand with basic knowledge of Unity. Some bits in the script were still confusing to me, in the sense that I didn't fully understand how they work the way they work but I think I'd need more C# knowledge for that. All in all very well explained!

@robertmcgraw2393

THANK YOU SO MUCH!! I am self-taught and I've been working with Unity and C# part time for the past couple of years! The inventory system is something that I have not found a decent tutorial on that didn't feel like a big pile of spaghetti!! You are SO clear and precise with your explanation of the "drag and drop" portion (which had always given me the most headaches)! I am definitely going now to watch your full inventory tutorial! I appreciate you SO SO much for helping me get over this massive hurdle!!!

@Santanu_Pal

Your teaching process is so clear and simple and very logical fold by fold.
Appreciate your hard work. Looking for more videos for you.

@digx7_studio60

5 minutes in and your already one of the best tutorial makers out there!

@brandonmitchell-kiss2533

This is one of the best tutorials I've ever seen for unity! Great teaching skills here!

@anthonymarra6553

if you like making your canvas "Screen Space - Camera" like me, you will need to change your OnDrag function since his code will teleport your item to where the canvas is supposed to be.  here is what worked for me.  public void OnDrag(PointerEventData eventData)
{
    Vector3 mouseScreenPos = Input.mousePosition;
    mouseScreenPos.z = Mathf.Abs(Camera.main.transform.position.z);
    Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint(mouseScreenPos);
    transform.position = mouseWorldPos;
}

@piotrszymanski8325

M8, you are one of the best! Everything showed, everything explained, nice clean and neat, without speeding and uselest trash talking, keep on going! Fingers crossed for your success!

@DwarvenStudios

Thank you so much, I was watching the full inventory tutorial but the dragging didnt seem to work, watched this tutorial and now everything works PERFECTLY.

On a side note, if anyone wants have more GO's like buttons under their items, dont add the grid layout group and just add an 
transform.position = parentAfterDrag.position at the BEGGINING of the onEndDrag method. If you add it in the end it will just offset your item which you do not want.

@lagrangepoint9386

My guy, you have criminally few subscribers for such amazing content.

@tower1990

The cleanest explanation on YouTube. Thank you so much sensei!

My stupid brain still don’t understand fully why the ray cast matters. As OnDrop should be triggered when a draggable item is released and dropped onto it. It should detect whatever object that’s colliding with it, and not the position under our mouse pointer. Strange.

Hopefully someone from the community could kindly explain the logic behind. Thank you!

@frog2091

If your item is being transferred to some crazy (30000000, 300000) coordinate once you implement the "transform. Position = Input.mousePosition" you might need to get to change it to "cameraNameExample.ScreenToWorldPoint(Input.mousePostition)" but as a new Vector 3 so you can ignore the Z axis.

@meenuchan7946

Thank you so much for this awesome tutorial. In my game, I had text as a child for my draggable item. I wondered whether raycast target will work or not. But it worked well.

@StealthyShiroeanGames

Thanks for this tutorial! I had no idea that Unity had these interfaces built-in. It's pretty cool how relatively easy it is to make a drag & drop system like this!

@boosterdraft

Thank you very much! Your tutorial was just what i needed today.

@jagdpanda

if you're struggling to get this to work on a screen space - camera canvas, try getting the hit.point of a raycast screenpointtoray in the ondrag event to put the item at

@konisan111

Hi! I know this video is two years old, but I found a bug. So when you hold one of the items, you can hold one more using the right click.  Great tutorial anyways, you have a new subscriber. <3

@tahahamifar

this video is absoulte Magic! better than any other tutorial about Drag & Drop system in youtube.