UI in Unity: Draggable Interface

Zac Bogner
2 min readMar 17, 2024

In the previous article, I introduced the first Event System Interface interaction by creating a Charge Bar.

This article, we will look at creating a Drag Event System Interface.

For this example, we will use 3 images (sprites).

We get reference to the Event Systems namespace, and add the IDragHandler to the class.

OnDrag method, we get the transform position of the data position from PointerEventData class.

We can attach the script to an image, and test out the Drag event.

Additionally, we can have effects where the OnBeginDrag and OnEndDrag methods have visual cues associated with the drag behavior.

Here I made a property reference to the Color data type, where we will get reference to the Image color property values.

We can adjust the alpha channel and set the color value applied to the image color.

Now we have a simple draggable event system to move our images around.

Next, we will look at how to snap the images to a drop item image slot.

--

--

Zac Bogner

Game Designer and Level Designer, formerly with Rainbow Studios. Focused in Unreal Engine with experience in Unity. Former Race Car Driver.