Triggering onClick if you drag your finger across a button

I’m experimenting with a mobile 2d shoot em up game and I’m trying to make the on screen controls a bit easier to use.

I want these buttons to activate when you drag your finger across them instead of having to touch up and back down. Sort of like a joystick. Here’s a gif to show what I mean.

I know how to do this with script and guiTextures but I want to use the new UI to take advantage of the built in scaling. Is there a way to do this in a script?

I probably would be tempted to handle this manually with a “IPointerDragHandler” in a custom component. You may be able to trigger the button or just do the graphical changes manually.

Thanks for the reply!

I actually found a way to do it. I just used an Event Trigger with an Image and used PointerEnter and Exit. I doesn’t work with the actual mouse but it works perfectly with Touches.

1 Like