Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Detect drag but pass through all other events?

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by johnmoff82, Sep 4, 2014.

  1. johnmoff82

    johnmoff82

    Joined:
    Nov 26, 2013
    Posts:
    2
    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?
     
    rakkarage likes this.
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,093
    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.
     
  3. mweldon

    mweldon

    Joined:
    Apr 19, 2010
    Posts:
    109
    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.
     
    blacksp1der and rakkarage like this.
  4. mweldon

    mweldon

    Joined:
    Apr 19, 2010
    Posts:
    109