Search Unity

[5.2.1p4] Image not blocking click?

Discussion in 'UGUI & TextMesh Pro' started by Matheuz, Oct 21, 2015.

  1. Matheuz

    Matheuz

    Joined:
    Aug 27, 2014
    Posts:
    30
    I just upgraded to Unity 5.2.1p4 and I am having some issues with the UI.

    My parent object has an image, a button and its child object has an image. When I click on the child object, it doesn't block the Raycast and the parent button (behind it) gets the click. I thought Images are supposed to block Raycasts. I even tried using a Canvas Group and setting its "Block Raycasts" to true, with no success.

    The only way I found to prevent the raycast propagation was adding an empty, non-interactable button to the child object, which I think is too much.

    Things I tried:
    • Adding a Canvas Group and setting "Block Raycasts" to false. Didn't help.
    • Setting "Raycast target" to false on both objects. Didn't help.

    Am I missing something or did something change on the last updates? Is that a bug?

    There is an example project (about 30Kb):http://www48.zippyshare.com/v/noIQmtnX/file.html Clicking on the black square triggers the white button.

    The only thing that helps is adding either an empty Button or a Selectable component to the child object. But shouldn't images block clicks by default, even if they are empty? Isn't it what of all these links is about?

    http://answers.unity3d.com/questions/816861/46-ui-image-is-capturing-clicks-how-to-prevent.html

    http://answers.unity3d.com/questions/830371/ui-46-image-blocks-mouse-click.html

    http://answers.unity3d.com/questions/827821/unity-46-ui-ignore-raycast.html

    Thread on Unity Answers, where I was discussing it before it started deleting my comments automatically and moved to the Forum: http://answers.unity3d.com/questions/1085178/ui-image-not-blocking-raycast.html#comment-1085771
     
    Last edited: Oct 21, 2015
    undefined666 and electric_jesus like this.
  2. undefined666

    undefined666

    Joined:
    Apr 3, 2018
    Posts:
    61
    have same problem on 2018.2.6f1.
     
  3. Romaleks360

    Romaleks360

    Joined:
    Sep 9, 2017
    Posts:
    72
    Still happens in 2018.3.2f1
    Never encountered this problem before updating from 2018.1
    Maybe some default behavior has changed?
     
  4. xxluky

    xxluky

    Joined:
    Dec 4, 2014
    Posts:
    19
    Hi, I have exactly the same problem after upgrading from 2019.2.14 (there has not been a problem) to 2020.1.13 - here I encounter with exactly same problem. Is it a bug or something has changed to UI??

    Did anyone marked this thread as a bug?? I think it's a bug that suddenly came in.

    Edit: I submitted a bug report. The support was very quick in responding. They wrote to me this:
    "This is the intended behavior of a Button and it's Child Image Object. Since the Button is Images Parent, Image has the same behavior as the Button."
    So I investigated more detaily the problem. I tried that in an empty project to make sure. It is true. But I found something in my project: I am using "OnPointerDown (PointerEventData eventData)" on every window / panel in my game. Something had to change because it acts differently now in later Unity releases. This method prevent panel from closing in older Unity versions but now it is not. I don't know what's the problem. It was blocking in 2019.2.14 but not in 2020.1.13. I did not get why.
     
    Last edited: Jan 4, 2021