1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Graphic Raycaster used to have a priority?

Discussion in 'Unity UI & TextMesh Pro' started by rakkarage, Dec 4, 2014.

  1. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    506
    Graphic Raycaster used to have a priority to allow ordering of input.
    Has this functionality changed in p1? Could not find in notes?
    Thanks.
     
  2. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    506
  3. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    Hmm i might have missed adding that to the release notes :(. That being said yes its been removed as its all handled internally now based on render order. Before you had to specify on each canvas the priority which at times could differ from the rendering order. This could cause confusing so now its handled for you.

    I should remove the documentation though :)
     
  4. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    506
    [​IMG]

    I have a full screen button on a [screen space - camera] canvas and a button in the corner on a [screen space - overlay] canvas
    the button on the overlay canvas is not clickable!?
    i used to be able to fiddle with GraphicRaycaster.priority to make this button clickable in last build rc3
     
  5. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    interesting once i get a build working again i'll take a look might be a logic issue with how those two canvas types work together. Did you file a bug by chance?
     
  6. _Daniel_

    _Daniel_

    Joined:
    Feb 28, 2007
    Posts:
    2,370
  7. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    yea :( a bug would just make sure it doesnt get lost/ forgotten about.
     
  8. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    506
  9. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
  10. T2Unity

    T2Unity

    Joined:
    Aug 21, 2014
    Posts:
    26
    I have same problem. I'm waiting for p2 passionately!
     
    rakkarage likes this.
  11. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    rakkarage likes this.
  12. T2Unity

    T2Unity

    Joined:
    Aug 21, 2014
    Posts:
    26
    I'v checked 4.6.1 and it is not fixed yet.
     
  13. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    506
  14. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    we've rushed a 4.6.1p1 to get this out asap (4.6.1 was already in the final stages when the bug was mentioned).
     
  15. goodtime

    goodtime

    Joined:
    Nov 8, 2012
    Posts:
    35
    I have also troubled by this problem.
    In particular, if I set the RenderMode to WorldSpace or ScreenSpaceCamera, when using the same time, problematic.
    Has been ignored that ScreenSpace-Overlay is always the front.
    Whether Depth of Camera is reflected, I do not know well.
     
  16. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    Did you pull and build the patch that is mentioned above?
     
  17. goodtime

    goodtime

    Joined:
    Nov 8, 2012
    Posts:
    35
    Sorry. I have not yet done.
    I can not immediately. Please wait at a later date
     
  18. brendan.vance

    brendan.vance

    Joined:
    Jan 16, 2014
    Posts:
    34
    What's happening here is that the default raycaster priority is int.maxValue and gets applied to any GraphicRaycaster on a non-Overlay canvas. The way I fixed it was to create a new component that extends GraphicRaycaster and overrides the sortOrderPriority property:

    Code (CSharp):
    1. public class WorldRaycaster : GraphicRaycaster {
    2.  
    3.     [SerializeField]
    4.     private int SortOrder = 0;
    5.  
    6.     public override int sortOrderPriority {
    7.         get {
    8.             return SortOrder;
    9.         }
    10.     }
    11. }
    But presumably the correct way to do this is to have GraphicRaycaster let us set the priority ONLY in cases where its canvas is set to something other than overlay.
     
    CreativeSpore and andsee like this.
  19. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    That pretty much is the issue along with some other things. the changeset above will resolve the issue until 4.6.1p1 is out.

    Its not required to have the priority at all as the other canvas types fall back to a distance sort so the closer one will receive the event first.
     
  20. BJO

    BJO

    Joined:
    Mar 25, 2013
    Posts:
    7
    Hi Phil, thanks for your responsiveness on this issue. I've tried pulling your branch, but unfortunately my issue still remains. It's a slight modification of rakkarage's. Instead of a screenspace-camera canvas and screenspace - overlay canvas, all my canvases are screenspace-camera. The canvases don't seem to be sorting correctly in the event system.

    Changing the if statement in GraphicRaycaster.sortOrderPriority to...

    if ((canvas.renderMode == RenderMode.ScreenSpaceOverlay) || (canvas.renderMode == RenderMode.ScreenSpaceCamera))

    ...seems to fix the issue.

    I've attached a sample project that demonstrates the issue.
     

    Attached Files:

  21. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    Yea i see what you mean, Issue would be that works great and all if you change the order in layer to be different. but if you instead changed the Sorting Layer it would have the same issue. :( Let me think for a bit.
     
  22. goodtime

    goodtime

    Joined:
    Nov 8, 2012
    Posts:
    35
    I tried Patch 4.6.1p1.
    It is running with no problems.
     
  23. BJO

    BJO

    Joined:
    Mar 25, 2013
    Posts:
    7
    Hi Phil, I tried the 4.6.1p1 patch, unfortunately this did not resolve the issue with RenderMode.ScreenSpaceCamera. Will this be resolved in the next patch?

    Thanks!
     
  24. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    That didnt make it into p1 or the next patch. I'm working on a more robust fix to cover more of these cases.
     
  25. kshaja

    kshaja

    Joined:
    Sep 22, 2010
    Posts:
    142
    Please consider some way to give us back the priority for canvas, as with p1 patch there is also an issue when I have button (Screen Space) and behind it is a button (World Space) and the World button is getting all the attention even if in the hierarchy the world button is first. In 4.6.0 and priority set in the right way everything worked fine.
     
  26. Ubiquit0us

    Ubiquit0us

    Joined:
    Jun 4, 2013
    Posts:
    2
    I am so happy. I was just looking at an issue of our debug menu not being clickable just before I left work. It is experiencing the problem listed here. I was confused and now I am not :)
     
  27. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    184
    Thank you Phil for looking into it. I have some temporary fixes to hold the QA testers at bay for now :)
     
  28. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    I'd love to get it working without the need for priority as it really can be a non intuitive way of working . My hope is the next version will work out of the box in even more cases than currently (i.e. sortingLayers taken into account).

    If you'd like send me your repo or a cut down version showing the issue and i'll try my best to make it work (also that way if i can't make it work i know priority should make a comeback).
     
  29. kshaja

    kshaja

    Joined:
    Sep 22, 2010
    Posts:
    142
    Thanks phil, I will try to make an example for you.

    In short what I think the problem is:

    I have an overlay buttons and then on start I load from resources a prefab with some world buttons.
    In 4.6.0. version on load and instantiate world buttons are behind the overlay buttons (set in priority).
    In 4.6.1 p1 this is not happening. Even after I manually move in hierarchy world buttons in run-time they are the one that have raycaster attention. And if I change the name of prefab to go first in hierarchy (which is not good for robust ui) its not working. I didn't try to set in code the sibling order after the instantiation but that is also not so intuitive for work with prefabs.

    Hope this helped a little.
     
  30. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    would anyone care to play with the sorting? I *think* its ready for prime time but would love for more real world testing. (although all the projects i've received so far work :))
     
  31. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    184
    Hey Phil,

    I would be down to test out your fix in our project. Our game is made of 100% Unity GUI with a mixture of overlays and camera canvases.
     
  32. kshaja

    kshaja

    Joined:
    Sep 22, 2010
    Posts:
    142
    I would like to test too.
     
  33. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    Ok I will get a repo ready today and post it here.
     
    BMayne likes this.
  34. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
  35. kshaja

    kshaja

    Joined:
    Sep 22, 2010
    Posts:
    142
  36. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    :( I'll look into it and make the required changes

    Edit: So looking at the examples you gave, i can click the button no problem (using the code version i gave out).
     
    xCyborg likes this.
  37. kshaja

    kshaja

    Joined:
    Sep 22, 2010
    Posts:
    142
    Phil, to be on the same track, are you using 4.6.1p1 with new repo?
     
  38. Umai

    Umai

    Joined:
    Jun 18, 2013
    Posts:
    74
    Sorry to bother everyone but I am suspecting I have run into this problem too... here is my thread... http://forum.unity3d.com/threads/prefab-buttons-stopped-working-since-unity-4-6-1.287429/

    In short: I have an "alert" panel covering all screen, its contained buttons are NOT tappable (well on some scenes they still are, but not on the main game scene since 4.6.1 - used to work on 4.6.0). On the game scene, I can access the covered game interface even though the alert is displayed on top of (as last sibling) all the other game elements.

    Running Unity 4.6.1f1

    Is there a fix for this somewhere? any workarounds? No? Is Unity UI touch priorities broken?
     
  39. xCyborg

    xCyborg

    Joined:
    Oct 4, 2010
    Posts:
    423
    Thank you very much phil, I just cloned your fork and compiled and so far PointerEnter and PointerExit events act as expected respecting the 2d layer order! Finally... I have to point however that the GetMouseButtonDown part is still glitchy and missing hits but at least now we got something going.
    Thank you very much again I encourage you all to hit this link: https://bitbucket.org/philip_cosgrave/philunity-uibugfixes/branch/eventsystemrewrite and compare the event interactions after you played with the project I attached for my issue here: http://forum.unity3d.com/threads/se...lliders-based-on-their-world-position.265619/
    I will take a good look at the diffs you introduced in your fork and get my hands dirty meanwhile you should issue a pull request to UI guys.
     
  40. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    13,876
    So forgive my ignorance, but what do I need to do to implement the new code repo? I haven't ever tried to get this deep into the engine before.

    My problem is slightly different, but I believe its the same issue. In my scene I have a bunch of cubes with colliders and event triggers attached. I also have a screen space - overlay canvas. The cubes render behind the canvas, but are blocking clicks on to the canvas. If I move the cubes behind the origin then everything works as expected.

    Reverting back to 4.6.0 fixes the issue. I might just sit on this version till someone can confirm this is fixed.
     
  41. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    Make sure only positive numbers are used while ordering canvases. I had an issue where canvas with sort order -1 was rendered behind everything, but captured the clicks. It was explained by Unity folks that there was a bug related to sorting raycasters. Though both canvas and raycaster now user canvas' sort order, canvas sort order is int, raycaster is unsigned int; -1 converted to unsigned int equals INT_MAX.
     
    rakkarage likes this.
  42. djdavidrevolution

    djdavidrevolution

    Joined:
    Nov 16, 2014
    Posts:
    6
    Hi guys,

    similar problem over here Keyboard not working in 4.6.1
    I'm glad to see you over here goodtime! I have sent you a private message because the problem that I mention above happens under your Utage code.
    By the way, patch 4.6.1p didn't solve my problem so I think that I will come back to 4.6.0 until goodtime or someone else can give me a solution.
     
  43. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    I'd try using the branch provided here it might solve your issue as its a more robust solution than p1.
    There are steps lined out on how to go about implementing the pulled repo. Its part of the overview page.
    I think its just 4.6.1 as we dont have a repo for the p1 releases
     
  44. judgeaxl

    judgeaxl

    Joined:
    Sep 29, 2014
    Posts:
    3
    Is the 5.0 beta using the same UI release as 4.6? I'm seeing this exact problem in 5.0.0.b18 as well.
     
  45. leon1985

    leon1985

    Joined:
    Jun 20, 2014
    Posts:
    5
    Come on ,plz give back the Canvas priority,I have installed the p2 version, but still have bugs when I have two canvas(both are Screen Space - Camera).
     
    Last edited: Dec 30, 2014
  46. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    Have you tried the branch posted in this thread? Chances are the priority wont make a return but the code in that branch will take over. If that branch still doesn't work please let me know so i can fix it in your case.
    I think so but not 100% sure what stuff got pulled to 5.0
     
  47. leon1985

    leon1985

    Joined:
    Jun 20, 2014
    Posts:
    5
    Hi,phil, I used your branch ,still no working for me . Maybe the attached project file can demonstrates what I am talking about.
     

    Attached Files:

  48. leon1985

    leon1985

    Joined:
    Jun 20, 2014
    Posts:
    5
    Finaly,I decide to change a little bit code in GraphicRaycaster.cs, and everything works for me now .
    Code (CSharp):
    1.  public override int sortOrderPriority
    2.         {
    3.             get
    4.             {
    5.                 // We need to return the sorting order here as distance will all be 0 for overlay.
    6.                 if (canvas.renderMode == RenderMode.ScreenSpaceOverlay || canvas.renderMode == RenderMode.ScreenSpaceCamera)
    7.                     return canvas.sortingOrder;
    8.  
    9.                 return base.sortOrderPriority;
    10.             }
    11.         }
     
  49. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,045
    Could you PM me, I just opened your project and everything seems to work as expected (based upon the text of "Why the red Image can not block Canvas_bottom's Button's click ? I can do it with the old graphic raycaster's priority!")
     
  50. kshaja

    kshaja

    Joined:
    Sep 22, 2010
    Posts:
    142
    Hi Phil,
    I have tried your repo in version 4.6.1 too, and the demo file I have send you is still no working for me :(.
    I will just wait than for the new version to see how it is behaving.
    For the 3D game I am developing, which is purely made with uGui, with lot of canvases, with all three render modes, with prefabs made of canvases,with drag and drops, everything is working perfect in 4.6.0.
    I think that the ability to set priorities by hand should be there like an option for a advanced users.