Search Unity

Easy way to figure out what's eating my button clicks?

Discussion in 'UGUI & TextMesh Pro' started by Renih, Aug 23, 2014.

  1. Renih

    Renih

    Joined:
    Jan 22, 2013
    Posts:
    6
    I don't recall anything from the tutorial videos about what things claim what clicks in what order - how is this determined? Can I have multiple stacked things all trigger a button click?

    I've tried using EventTriggers as well, something still eats the clicks unless I put it as a direct child on the canvas (which really isn't going to work for me, I'm relying on layered anchoring for formatting and size setting).
     
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Well you need to have UI elements on the canvas for raycasting to work. You could write a custom raycasting module if you wish to do your own logic here. Click 'order' is just the click will be sent to the topmost element.
     
  3. Renih

    Renih

    Joined:
    Jan 22, 2013
    Posts:
    6
    How is "topmost element" determined? Closest to the canvas?

    It's a UI element. Basically, here's the two situations:
    Hierarchy A (OnMouseDown event trigger does not register):
    Canvas
    Left Anchor Panel (UI Panel)
    Grid Container of Buttons (RectTrans)
    Button (I don't need the transitions, so RectTrans with an image and EventTrigger set up for OnMouseDown)
    UI Image (border for buttons)​
    Right Anchor Panel
    Hiearchy B (OnMouseDown event trigger does register - it's the same GameObject, just dragged down in the hiearchy)
    Canvas
    Left Anchor Panel
    Right Anchor Panel
    Button (same one, works!)
    This is the kind of thing I expected to just work - with NGUI I have a "Depth" field to control interactions, is there an equivalent here to determine "topmost element"? Z Depth doesn't seem to do anything

     
  4. Renih

    Renih

    Joined:
    Jan 22, 2013
    Posts:
    6
    Finally dug down to all the things that were stealing clicks - next question (I wouldn't have to worry about click order or depth if this wasn't the case) why does anything without an EventTrigger ever eat away the clicks of things with event triggers? If I reduce the rectTransform size of my anchors to 0 width 0 height, and turn off the object I have drawing borders, the clicks register. The thing drawing the border is just an image with a sliced sprite, yet it steals the clicks from things with Event Triggers :(