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

Subcanvases. Is there any reason to use them? Also Override Sorting

Discussion in 'UGUI & TextMesh Pro' started by Nanako, Aug 4, 2015.

  1. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    So i've been struggling with some errors in another thread, http://forum.unity3d.com/threads/invalid-aabb-errors.344280/#post-2228543
    we've finally found the exact cause of the errors, with help from the wonderful @Lysander

    The issue was the Override Sorting setting being checked on several subcanvases

    To be clear, by subcanvas i mean a canvas which is a child, (directly or not) of the main top-level canvas. Every UI Element has to be under at least one canvas.

    Unchecking Override Sorting caused the errors to go away, however this creates a new problem. The entire content of the canvas turns invisible. With farther poking around, i was able to fix this new problem by simply removing the "Canvas" component from those subcanvases.

    Now it works perfectly, but they're also not canvases anymore. Now they're just empty gameobjects with some children. And aside from not being broken, i can't discern any functional changes to their behaviour

    I'm not sure what to make of this. This experience indicates that sub-canvases just don't work. And i would like some more feedback on this. Is there any reason to use a subcanvas, rather than just an empty gameobject, or another UI element?

    What does a canvas even do if it's not the root? What functionality can it provide.?


    My other related question is about the Override Sorting setting. I've done my best to comb through the unity documentation, and i can't seem to find any useful information about what this setting does.
    Can anyone write me a brief overview of how UI sorting actually works? And how might the OverrideSorting setting change that behaviour ? What situations are there where using it would be appropriate?

    And perhaps most importantly, how or why could the lack of that setting cause my canvas content to be invisible?

    That's a lot of questions, chip in any information you might have <3
     
    harrymuana likes this.
  2. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    A couple of interesting points I've noticed:
    1. A subcanvas does not have the ability to choose a render mode- it's stuck with whatever mode the top-most canvas chooses. This makes a lot of sense, I think, as conflicting rendering systems would just be too confusing, not mention making the parent/child relationship have a lot less meaning.
    2. The only options a subcanvas seems to possess are the ability to override the sort layer or choosing whether its children are pixel-perfect or not. The former gives off a lot of errors if the subcanvas is lower than the parent canvas (broken?) and the latter seems like a silly thing if it's the only thing the component does.
    3. Making an override layer that's greater than the parent layer does not give errors. This makes me think that maybe the idea isn't sorting in relationship to the parent, but rather in relation to eachother as sub-canvasses. If the parent is 0 and two children are 1 and 2 (or any other numbers greater than 0), it appears to function properly. Is this intended?
     
  3. clintonb

    clintonb

    Joined:
    Dec 14, 2013
    Posts:
    15
    Three years later, I'm facing the same problem.

    The answer to the first question is: yes, subcanvasses are great for optimization purposes.
    The answer to the unasked question ("Why doesn't this work?") is: every canvas (and subcanvas) needs a Graphic Raycaster component if it is to receive anything from the event system.

    Source:
    (watch from this point for 30 seconds -- actually, the whole second half of the video is on optimizing the UI).
     
    rakkarage likes this.