Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity UI UI Canvas subelements drawn in wrong order

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

  1. JuhoLyde

    JuhoLyde

    Joined:
    Nov 5, 2015
    Posts:
    1
    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.

    Notes:
    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.