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

How do I make Unity's new UI render elements by Z-order?

Discussion in 'Scripting' started by zarawesome, Nov 24, 2014.

  1. zarawesome

    zarawesome

    Joined:
    Jul 25, 2014
    Posts:
    7
    I give up. I don't understand how sibling indexes, graphic raycasters, layer orders and the moon's position overhead combine to influence the arcane sequence by which UI elements get rendered.

    Just tell me how to go back to a sane system based on Z coordinates.

    Please.
     
  2. Korno

    Korno

    Joined:
    Oct 26, 2014
    Posts:
    518
    I found the order that they appear under the canvas object in the editor affected (effected?) the render order.
     
  3. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    As far as I know you can't do that. You could write your own scripts that translates z coordinates to sibling indices. But that means you still need to fully understand the current system.

    If you describe cases for which you can't find a solution, I am sure you'll get help here in the forum.
     
  4. zarawesome

    zarawesome

    Joined:
    Jul 25, 2014
    Posts:
    7
    OK, one of the many issues I'm having: I have two canvas objects and one will render behind the other no matter how much I fuss with the numbers of both.
     
  5. Korno

    Korno

    Joined:
    Oct 26, 2014
    Posts:
    518
    Is there a reason both UIs cant be placed in one canvas?
     
  6. zarawesome

    zarawesome

    Joined:
    Jul 25, 2014
    Posts:
    7
    What's the point of having multiple Canvas objects, then?
     
  7. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    That is exactly how they are supposed to work.
     
  8. zarawesome

    zarawesome

    Joined:
    Jul 25, 2014
    Posts:
    7
    Got it. "Screen Space - Overlay" and "Screen Space - Camera" do not mix, and if an object is in "Screen Space - Overlay" it won't render child meshes. So everything has to be Overlay.

    Dantus: Yeah, what I meant is, Canvas A would render behind Canvas B no matter what values I inputted on either. This turned out to be because of the Overlay/Camera discrepancy.