Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug World space canvas not following sorting group

Discussion in 'UGUI & TextMesh Pro' started by graybear209, May 18, 2021.

  1. graybear209

    graybear209

    Joined:
    Nov 18, 2018
    Posts:
    11
    Hi,

    I'm having some rendering order issues on a playing card prefab which mixes sprites and a world space UI canvas with TMP text.

    I want to be able to overlap cards and have one card cover the other so I added a sorting group to the root of my card prefab. For whatever reason, changing the order at the sorting group level seems to ignore my world space canvas.

    My card is structured such that everything is on the same sorting layer and layering on the card itself is done via "Order In Sorting Layer":
    • Order in sorting layer 0
      • CardBorder sprite
    • Order in sorting layer 1
      • CardBackground sprite
    • Order in sorting layer 2
      • Suit sprite
      • Mini suit sprite
      • World Space canvas (containing TMP_Text showing the card's value)
    Everything is fine if the SortingGroup object on the root of my prefab has it's "Order in Layer" value set to anything between 0-2. BUT if I change the "Order in Layer" to 3+ the card's value text disappears (but everything else renders correctly).

    This makes me believe that the Sorting group is pulling up all the other sprites on the card above the Canvas because the Canvas is being ignored by the Sorting group...

    Why is my canvas not being included in the sorting group? (Is this intentional?) Is there some way to include the canvas contents in my sorting group? Is there some other way to setup overlapping cards?

    (I'd really prefer to not have to bounce all my text to sprites!!)

    Thanks!

    What I'm seeing / How the editor is configured:

    CardSortingGroup0.png
    Card prefab working correctly

    CardSortingGroup9.png
    Card prefab when root sorting order is changed

    HierarchyAndCanvasInspector.png
    Inspector configuration of my canvas that displays the card's number text + Prefab hierarchy

    HierarchyAndRootSortingGroupInspector.png
    Inspector configuration of my sorting group at root of prefab (in this case card would render incorrectly because sorting order is at 9) + Prefab hierarchy
     
  2. graybear209

    graybear209

    Joined:
    Nov 18, 2018
    Posts:
    11
    Any word on how canvases are supposed to interact with sorting groups?
     
  3. Chris-V

    Chris-V

    Joined:
    Jul 29, 2015
    Posts:
    8
    Looks like this is fairly old, but do you recall if you ever figured this out? Experiencing a similar issue.