Simple Drag Drop (Unity Tutorial for Beginners)

preview_player
Показать описание
Let's make a very simple Drag and Drop in Unity, great for an Inventory System.

Simple Inventory System in Unity (Store, Use, Stack and Drop Items)

If you have any questions post them in the comments and I'll do my best to answer them.

See you next time!

#unitytutorial #unity3d #unity2d

--------------------------------------------------------------------

Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.

I've been developing games for several years with 7 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.

--------------------------------------------------------------------

Рекомендации по теме
Комментарии
Автор

Here's a really simple video on something that is extremely useful! Inventories, Skill Bars, etc.
Play 7 Awesome Games (Action, Strategy, Management) and Help Support the Channel!

CodeMonkeyUnity
Автор

The events explained by you are just fascinating, this guided me a lot and helped me make a custom inventory for my game!

Shrarder
Автор

This 10 minute video saved me probably three hours worth of effort, thank you very much.

tjaartvanderwalt
Автор

So simple and nice! After 10 hours spent for my experiments with drag and drop you show me how to do this with a few lines of code... Thank you!

timurnurlygayanov
Автор

If anyone is finding this video (because CM is amazing and you should be finding them) and trying to do this with the new Input system. Go to your camera and add a Physics Raycaster OR Physics 2D raycaster to your camera first. Then the events they are showing you will work. (If not using UI, I believe you may need to add a collider to the object)

Hope this helps someone!

TMosier
Автор

Thank you so much for making this video. I've been going crazy for an hour trying to get OnDrop events to trigger by messing with Override Sort Order, but what I really needed to do was add a CanvasGroup and blockRaycasts as per your video. THANK YOU!

robmattson
Автор

Using those interfaces is really neat! Thanks a ton for this amazing tutorial 👏🏻 To implement a whole drag n drop inventory is a hell of a project but it so much worth it once it is up and running. 😎

joshuadrewlow
Автор

Man, I had troubles getting DragDrop to work properly especially when I get into the NRE, long before I found this tutorial and adapted it to my code and made it work just the way I wanted. Thanks, Code Monkey.

Zyugo
Автор

Thank you CodeMonkey as always! I made a slightly different variation that uses Triggers for the itemSlot to talk with the DragDrop class to tell it where to place the item if any part of the item enters the ItemSlot rather than just the mouse cursor.

It's really awesome seeing your way of doing it, and discovering another way of doing it to fit my specific desires!

personalgamedevyt
Автор

Your videos are always on point, best topics 👌

dio
Автор

Thank you for the tutorial. It's very concise and helpful.
A small tip: you don't need to add a canvas group to block raycasts for the dragged object, just grab its image component and set raycastTarget = false;

mboog
Автор

This man, without a doubt, creates some of the best tutorials. His tutorials are easy to follow and are very useful. Stay blessed, Code.

theplaymakerno
Автор

in case any other UI noobs out there run into the same issue...
my console wasn't showing any click event debug messages-- the problem was i tried to make my own canvas by making an Empty and adding a Canvas component to it -- which is not the right way to go about it. : )
To solve this, go to the hierarchy and right click > UI > Canvas. This will generate a good Canvas with a graphic raycaster, and an Event System, both of which are needed for these scripts to work as shown!

kpickett
Автор

YEeEeEeEeeeeEEEsS! OMG thank you so much this is exactly what I needed!

kleinerobin
Автор

One of the best Unity channels of Youtube...

martinds
Автор

Where ever i search about something, i find u immediately 😧, u are legendary man thank u a lot 🙏

zezooalzezoo
Автор

Clean, simple and overall a perfect video! Appreciated a lot.

mertcanguven
Автор

👏🏾👏🏾👏🏾👏🏾👏🏾
Great great tutorial!
Fast and objective.
Thank you!!

EspiritoDoLugar
Автор

You have some of the best tutorials! Great job!

OPTactics
Автор

Super clear, and very easy to use. Thank you Master.

jean-michel.houbre