- Home /
How can I make a Unity 4.6 UI object trigger when I drag something onto it?
I'm currently making a word-puzzle game for smartphones that heavily relies on the GUI. It consists of alphabetical letters and a serie of boxes in which the player can put the letters onto. I want the player to be able to drag a letter and drop in onto an empty box. The empty box must be (or has) some kind collider which triggers when something else is dragged onto it.
(GameObject) Letters have a Rect Transform, Image and RigidBody2D component
(GameObject) EmptyBox have a Rect Transform and Image component
Normally I'd use a simple BoxCollider2D and it's OnTriggerEnter2D function, I can't get the colliders to scale along with the resolution of the screen and I don't know how to resolve that.
Are there any other ways to see if an draggable object crosses/collides with another UI object?
Btw. I use the new Unity 4.6 UI system!
Answer by Mmmpies · Jan 12, 2015 at 12:19 PM
You could do a lot worse than follow this tutorial DragMenuTutorial
20 minutes long but pretty short when you should have a reasonable menu within the hour.
If you're still struggling after that let me know or you may even get a reply from @BoredMormon who made that tutorial.