Detect drag but pass through all other events?

I have a screen space GUI that rotates when you drag it. I also have buttons that you can click. I’d like to be able to tap and drag almost anywhere on the screen (including certain buttons) to rotate it, but still be able to tap those buttons and get an onClick. (The buttons should not get a click if the screen is dragged more than a certain threshold.)

Currently, I have a full-screen transparent Image with a script that implements IDragHandler in front of everything. However, it apparently captures all events, including onClick, so the buttons underneath do not receive those events. Is there a way to ONLY detect IDrag* events and pass through all others? Or is there a better way to accomplish what I’m trying to do?

2 Likes

The ‘more correct’ way (in terms of how the system is designed) would be to add the drag script to the UI elements you wish to allow the dragging on. You could also write a custom Input module based on the StandaloneInputModule that will pass drag events through. This isn’t something we felt would be desirable is most use cases so didn’t design the system that way.

I disagree with every fiber of my being about this not be desired functionality. The ability to add functionality to a UI object without breaking the objects that contain it seems kind of fundamental, IMO.

7 Likes

I think I found a clumsy workaround. See Passing an event through to the next object in the raycast - Unity Engine - Unity Discussions

1 Like