Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Unity UI UI Canvas subelements drawn in wrong order

Discussion in 'Unity UI & TextMesh Pro' started by JuhoLyde, May 16, 2018.

  1. JuhoLyde


    Nov 5, 2015
    Really hard for me to explain what the actual issue is but I'll try to describe what's going on.

    Essentially I have a sub gameobject under a canvas that is drawn before/under a another sub gameobject that exists in an canvas that is positioned lower/earlier in hierarchy. Issue can be reproduced easily but requires a very certain steps in terms of activating elements in different canvases.

    Scene Hierarchy:
    Root Canvas
    <other objects>
    - Sub Canvas A
    ---Panel GameObject 1A
    - Sub Canvas B
    -- Panel GameObject 2B
    -- Panel GameObject 3B
    <other objects>

    Required Sequence:
    > Open "1A"
    > Open "2B" (1A stays open)
    > Close "2B"
    > Close "1A"
    > Open "3B"
    > Open "2B" (3B stays open)
    > Close "2B"
    > Close "3B"
    > Open "1A"
    > Open "2B" (1A stays open)
    -- Issue is visualized:
    * 1 stays on top of 2

    order canvas sub elem issue.png
    Sequence visualized: slide 3 should be the correct order of things instead of the end slide.

    Current hierarchy contains many nested canvases (some contain no active content on scene load)
    Open enables and tweens the gameobject child content scale and canvas group alpha (dotween)
    Close tweens child content scale and alpha and disables it.
    Canvas.ForceUpdateCanvases had no effect
    Canvas.Rebuild ( CanvasUpdate.PreRender/Layout ) [no effect] < on panel to be opened (shared baseclass)
    Moving some objects around manually in hierarchy fixes the issue.