Search Unity

Upgrading to Unity 5.2 - UI Problem with Raycast Target

Discussion in 'UGUI & TextMesh Pro' started by TitanUnity, Sep 8, 2015.

  1. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Hi,

    Maybe I'm misunderstanding something simple here, but I just upgraded to Unity 5.2 this morning and I'm now having several issues with many of my UI buttons.

    After troubleshooting for about 3 hours I discovered that some of my buttons fail because the touch seems to interact with objects beneath the layer my button is on. This was previously never a problem. In the screenshot below, there are areas of the Yes and No buttons that don't respond because it seems the click / touch interacts with objects beneath the popup menu.

    In this example, I have a Confirm screen with a semi transparent disabler background that previously prevented interaction with the objects below. Now with 5.2 it seems that in some odd cases a touch can interact with objects below the disabler.. weird.

    Confirm.JPG

    I'm going to continue experimenting to provide more clarity here, but if anyone knows something simple that changed in 5.2 that would cause this issue please let me know.
     
    JoRouss, Maelrann and rakkarage like this.
  2. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Some additional information about this situation:

    In the screen shot above, I'm using two canvases:

    Canvas Foreground:
    Contains the blue popup menu and semi-transparent black disabler screen

    Canvas Background:
    Contains the shop options that you see in the background.

    It seems that the "Yes" / "No" button problem can be fixed by unchecking the "Raycast Target" on the Image component in the gameobjects in the background. That of course is not a viable solution since those objects need to remain interactable.
    I must be missing something simple that has changed in 5.2. Will keep digging.
     
  3. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    I'm using canvas render mode "Screen Space - Camera." It looks like the issue goes away if I change to render mode "Screen Space - Overlay"

    Does this make sense to anyone? It looks like I would need to make substantial changes to support Overlay.
     
  4. Vickery

    Vickery

    Joined:
    Oct 31, 2014
    Posts:
    5
    Hi Titan having the same issue. Finally got other scripts upgraded to 5.2 and now all my button clicks don't work. I don't really have the option to use Overlay as I have particles that are part of my UI. Any more information on this at all? I will keep digging around to see what I will find but need this sorted. Seems like a huge oversight if this is a bug.
     
  5. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Ok good to hear it's not just me. Here's another example where buttons don't work:
    Layers.JPG

    Clearly the tabs at the top of the interface are in front. In this example, the black gradient (setup as an Image component) on the rear layer had the "Raycast Target" checkbox checked by default. If checked, none of the buttons in the foreground work.
     
  6. Shii

    Shii

    Joined:
    Nov 23, 2014
    Posts:
    31
    Maybe not related, but after upgrading my project to 5.2 mouse stopped interacting with buttons. Fixed this by removing checkbox "Force Module Active" in EventManager's Touch Event Module (script) gameobject.
     
    Flybye likes this.
  7. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Yea I looked into that, but mine is already unchecked. Couldn't find great documentation on that either btw.
     
  8. Vickery

    Vickery

    Joined:
    Oct 31, 2014
    Posts:
    5
    My setup is having multiple canvas'
    one for common UI (including back, home and help buttons)
    another for standard views
    another for popups

    It seems all touches are hitting the popup before hitting the common UI even though the sorting layer, and hierarchy order means the touches / mouse input should hit the common > Popup > standard.

    Been bashing my head against this for a while and for now means I will roll back to 5.1 but there are some horrible bugs that 5.2 fixed.
    Will have to look into this more tomorrow when I have brain power.
    Will post on here if I find a fix or will create a test project and submit a bug report.
     
  9. jjaros

    jjaros

    Joined:
    Jun 18, 2015
    Posts:
    7
    I have the same issues with buttons and also DropComponent stop working for me (it looks like another panel must block the one with DropComponent), I have to dig in later. For now I rolled back to 5.1.3.
     
  10. Oscaruzzo

    Oscaruzzo

    Joined:
    Jan 26, 2015
    Posts:
    17
    eisie likes this.
  11. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    I don't think that is related, I did try recreating the EventSystem component just to see but no change... still having issues. If I can't figure it out in the next few hours I will be rolling back to 5.1.3
     
  12. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Still no luck here, I've reverted back to 5.1.3p2, will wait for patch or new details.
     
  13. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Could someone give us a repo project?
     
  14. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    I'll get you a project shortly... need to reinstall 5.2 to create the issue =)
     
  15. jhkimblue

    jhkimblue

    Joined:
    Mar 27, 2015
    Posts:
    14
    i already report it. i guess you guys miss include this one from previous version.
    check eventsystem's raycastcomparer. when i check the bitbucket unlike web source, zip version has a bug which was existed before 5.1.
     
  16. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Do you have a bug number?
     
  17. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Ok here is a reproduction project example:

    If you click the Foreground button in the area that overlaps the Background button, you'll notice that foreground button doesn't work. It seems related to how many panels nested the button is within the hierarchy. You'll notice this difference in my two projects.
    Buttons.JPG

    In the broken example, I've nested the button multiple panels deep:
    Broken1.JPG
    Download Broken Example:
    https://drive.google.com/file/d/0BwL7QqsvL2_EcEhKMUVIZDZyVFU/view?usp=sharing



    In the working example, I've nested the button only a single panel deep:
    Working1.JPG

    Download Working Example:
    https://drive.google.com/file/d/0BwL7QqsvL2_EVlBHTG8tbkQxSFk/view?usp=sharing
     
  18. RDeluxe

    RDeluxe

    Joined:
    Sep 29, 2013
    Posts:
    117
    Same problem here. That's frustrating.
     
  19. jhkimblue

    jhkimblue

    Joined:
    Mar 27, 2015
    Posts:
    14
    It's Case 726055 currently, and it is happened before 5.1 at case 707026.
     
  20. RDeluxe

    RDeluxe

    Joined:
    Sep 29, 2013
    Posts:
    117
    I managed to solve my problem by following @Shii advice (touch module). I had another eventsystem being created at runtime, which is weird (we use several scenes merged together, it may come from that).
    Seems related to touch control in some ways.
     
  21. geff

    geff

    Joined:
    Mar 3, 2013
    Posts:
    28
    Hi, same problem here with UNITY 5.2

    Deleting and adding EventSystem object in hierarchy mysteriously fixed that problem.
     
    rakkarage likes this.
  22. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    I tried deleting and readding the EventSystem object with no success.
     
  23. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    I just tested this with one of our fixing branches and the problem does not appear. We are working to get this out ASAP
     
    JoRouss likes this.
  24. Peez-Machine

    Peez-Machine

    Joined:
    Jul 30, 2013
    Posts:
    27
    I submitted a bug report (and suggested fix) last week. I'll post a somewhat briefer version here.

    All 2D-based raycasting done by Physics2DRaycaster and GraphicRaycaster is borked because they use Raycast/RaycastAll (designed for coplanar and "flattened" coplanar intersection -- like laying string on a piece of paper with a box drawn on it) instead of GetRayIntersection and GetRayIntersectionAll (designed for non-coplanar intersection, like throwing a dart at the paper). This causes a number of issues related to mouse pointer collision when used with in-world objects or world-space canvases, namely:

    1) Collision depth is screwy (the issue the OP seems to be experiencing). Since raycast blocking by 2D objects is done by the faulty raycasting, you get situations where rays may either be arbitrarily blocked or permitted to pierce.

    2) Objects behind the camera can still trigger collisions. Again, seemingly because the raycast method being used is strictly 2D (and thus ignoring depth), whereas GetRayIntersection is correct for intersecting a ray and a 2D object in proper 3D space.

    3) Perspective cameras are borked, typically in favor of overdecting collisions for objects directly in front of the camera. In a perspective camera, a ray should be cast from the focus of the camera toward the pointer's world-space position on the near clipping plane, which is exactly what GetRayIntersection would do and exactly what Raycast does NOT.

    The fix is to change Physics2DRaycaster and GraphicRaycaster to use the appropriate GetRayIntersection* method (I believe the 2D raycaster returns an array of hits, and Graphic only returns one, but I'll leave that to the engineers). I've been able to work around it by creating subclasses with those very changes, but they should definitely be codified. Efforts to instead update my local copy of the Unity UI dlls (obtained and edited via the Unity UI Bitbucket repo) have been stymied by the fact that UnityEngine.dll's definition for UnityEngine.Input.getMouseScrollDelta seems to call an undefined getter method or possibly needs to be decorated as an InternalCall? A bit fuzzier on that.

    EDIT: It's worth noting that I found/worked around these issues while on 5.1.1f, I think? If you're ONLY getting the error in 5.2 then that's certainly strange to me.
     
    rakkarage likes this.
  25. antonov_3d

    antonov_3d

    Joined:
    Jan 21, 2015
    Posts:
    28
    this is what happened to me and it works.
     
    ericthelawrence and rakkarage like this.
  26. Vjosey

    Vjosey

    Joined:
    Aug 16, 2012
    Posts:
    4
    I had the same issue.but It's working now. I just had to add a fresh EventSystem.
     
  27. AleKahpwn

    AleKahpwn

    Joined:
    Jun 11, 2013
    Posts:
    2
    A lot of issues seem to popup in 5.2 - I can't get a visual caret on any of my input fields, dropdown menus work fine the first click, but after that don't drop down again.

    I've added fresh event systems to no avail.

    Is rolling back to 5.1 the best solution?
     
    JoRouss likes this.
  28. Vickery

    Vickery

    Joined:
    Oct 31, 2014
    Posts:
    5
    I rolled back to 5.1.3 for now will have to wait for 5.2.1 to be released which will hopefully solve some of the isues.
     
  29. Crazydadz

    Crazydadz

    Joined:
    Mar 29, 2012
    Posts:
    50
    OnClick event seems to get fire only when you release the mouse on the image and the PointerUp event only get fire when you hold down your mouse on the image and slide out of the image and release the mouse). Plus, calling the gameObject.setActive(false) is firing up PointerUp event even if the mouse isn't on it. Need to do more test to be sure.
     
  30. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    I have this same problem.

    Also when the project is running in the editor. I can't drag objects around in the hierarchy to rearrange them. I wonder if it's related to this somehow?
     
  31. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    Has this been released yet?
     
  32. johnpine

    johnpine

    Joined:
    Sep 19, 2015
    Posts:
    26
    just tried 5.2.0p1 this is still broken and there was no mention in release notes.
    half of the gui is not working. clicks go thru buttons. completely hopeless. whole canvases unclickable randomly.
    in editor and in builds. had to roll back to 5.1.3p3
     
  33. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Yes, confirmed with the test project, this issue has not been fixed.
     
  34. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    Ya p1 did not fix my companies project either....
     
  35. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
  36. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Just installed 5.2.1f1, tried the test project again, and the issue remains.
     
  37. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    Ya its still not fixed...
     
  38. k0mbain

    k0mbain

    Joined:
    Nov 1, 2012
    Posts:
    22
    The same here, moreover the performance of UI drastically decreased. Can anyone paste a link to issue tracker to bump up the votes?
     
  39. Maelrann

    Maelrann

    Joined:
    Dec 3, 2013
    Posts:
    1
    I have same problem, changing EventSystem did not help.
     
  40. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    472
  41. redsend

    redsend

    Joined:
    Jun 3, 2013
    Posts:
    2
    I have the same problem with unity 5.2.1f1... changing the EventSystem did not help...
     
  42. JoRouss

    JoRouss

    Joined:
    Apr 1, 2014
    Posts:
    53
    Omg I was about to throw my computer by the window.... I'm happy to see it's a bug haha. I lost a whole day trying to fix this, that's the frustrating part.
     
  43. johnpine

    johnpine

    Joined:
    Sep 19, 2015
    Posts:
    26
    this is starting to be completely hopless developing with Unity. currently ALL official builds of Unity are broken.
    4 5.1 and 5.2

    In Unity 4 the binaries crash on iOS. ( proof: http://forum.unity3d.com/threads/crash-upgrading-to-4-6-8p2-on-application-loadlevel.354899/ )

    In 5.1 sprite packer is broken. ( proof: http://forum.unity3d.com/threads/cannot-load-atlas-during-build-enter-game-missing-file.340440/ )

    In 5.2 the GUI is completely broken and it leaks memory. Your game will eventually crash in just by showin a text.
    ( proof: this forum thread )

    Absolutely frustrating in searching the working Unity version.
    My projects all have this problems. Can't do anything.
     
  44. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    65

    We are using 5.1.0f3 as our stable version at the moment.

    The Gui memory leak is fixed in 5.2.1p1 , but there are a million and one other issues with it :(
     
  45. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    So the or
    Could you try out 5.2.1p1? According to our issue tracker thats where the issue was finally pushed.
     
    steve-yeager and holliebuckets like this.
  46. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Ohhhhhh snap... it works on the test project! I'll switch our main project over and test this out shortly.
     
  47. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Well, I migrated our game project over to 5.2.1p1 and we're seeing a ton of fun new problems. No idea what is wrong... so while the button click issue as demonstrated in the test project seems to be working, we're now having loads of rendering problems on the screen that I can't explain. Here are a few screen shots of what I mean:

    Random black boxes appear in our interfaces?
    BlackBoxes.JPG

    Odd Artifacts appear in most interfaces:
    Artifcacts.JPG

    Some interfaces are 100% totally jacked up.
    TotallyJackedUp.JPG

    More black boxes?
    BlackBoxes2.JPG


    I'll post details about our setup in the next post
     

    Attached Files:

    JoRouss likes this.
  48. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Here are specific notes about our configuration that might be relevant to solve this issue:

    - We're building a 2D game with an orthographic camera
    - We use several canvases to control UI layering. Each canvas is given a sorting layer to control render order
    Hierarchy.JPG

    - The images above are taken from the Editor while setup for an Android build
    - We're using the following 3 compressions depending on the asset:
    Compression1.JPG
    Compression3.JPG
    Compression2.JPG

    - We use the Sprite packer to optimize and pack like-compression assets together to minimize our sheets

    If there is any other info that would be helpful to track down this issue let me know. I'll be reverting back to 5.1.3p3 for now... again.
     
    JoRouss likes this.
  49. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Are you using a bunch of empty Images (possibly for masking)? If so thats a known issue that i'm working on getting a fix out for (couple P1 bugs that need fixed before i can start the whole process). Adding any sort of texture (even a basic empty white one) anywhere a Image doesnt have a sprite specified should fix it for now.
     
    jprocha101 likes this.
  50. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    We do have some locations where an Image component does not have a sprite set until runtime... but not very many. An example would be in the case of a custom button where the user has a choice to select 1 of 3 mutations. When this interface opens, the system sets the sprites to the correct graphic for the mutations being presented. As far as for masking purposes, no, we're not using any empty images to my knowledge.

    I've reverted back to 5.1.3p3 for now, but could try again if you have specific suggestions or when a patch is available.