Search Unity

  1. Unity 2018.3 is now released.
    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. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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.