Search Unity

Unity UI Canvas hierarchy/drawing order broken after upgrade to Unity 2021.3

Discussion in 'UGUI & TextMesh Pro' started by solinvictus1313, Jul 14, 2022.

  1. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    We're all waiting for the fix that should of been released yesterday, actually should of been released on 23rd August but they're behind on their own 2 week schedule.
     
  2. SampsaPlaysome

    SampsaPlaysome

    Joined:
    Oct 20, 2019
    Posts:
    34
    Downgraded to 2021.3.5f1 and now it seems to be in working order.

    TBH the fix should have been released 28 Jul in 2021.3.7f1 already. This feature has been broken for almost 2 months now. Totally unacceptable for LTS release.
     
  3. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Agreed!
     
  4. yuliyF

    yuliyF

    Joined:
    Nov 15, 2012
    Posts:
    197
    U2021.3.9 is out : link
    I hope, out UIs will be fixed =) .. loading 3.9
     
  5. juanfornos

    juanfornos

    Joined:
    Feb 17, 2018
    Posts:
    10
    The drawing order appears to be working as expected on 2021.3.9 but they introduced a new bug: graphics in nested canvases are still blocking interactions even when the parent canvas is disabled (this means the graphics aren't rendered but still blocking the mouse input).

    Edit: typos

    Edit 2: in my use case this means that EventSystem.RaycastAll is returning results with those graphics even when they aren't rendered. Not sure about other implications with other Unity systems. As a workaround, you can toggle the sub canvas. I already reported the bug.
     
    Last edited: Sep 26, 2022
  6. Asgarde26

    Asgarde26

    Joined:
    Jul 24, 2019
    Posts:
    3
    uncorrected bug in U2021.3.9
    UI still broken.
     
  7. ArthurAulicino

    ArthurAulicino

    Joined:
    Sep 4, 2018
    Posts:
    4
    I updated from 2021.3.5f1 to 2021.3.9f1, and now my unity editor randomly crashes.
    It might be a new bug since this didn't happen before.

    Crash 1 stack trace:
    #0 0x00000103ae9e6c in UI::Canvas::SetSortingOrder(short)
    #1 0x00000102b8ae3c in Canvas_Set_Custom_PropSortingOrder(ScriptingBackendNativeObjectPtrOpaque*, int)
    #2 0x00000369a71d7c in (wrapper managed-to-native) UnityEngine.Canvas:set_sortingOrder (UnityEngine.Canvas,int) [{0x379be6d18} + 0xcc] (0x369a71cb0 0x369a71e10) [0x146d96a80 - Unity Child Domain]


    Edit:

    This one also started happening:

    Crash 2 stack trace:
    #0 0x00000105ac564c in UI::CanvasRenderer::InitializeClass()::FunctorImpl_966kCanvasHierarchyChanged::Call(void*, int, MessageData&)
    #1 0x00000104f07474 in MessageHandler::HandleMessage(void*, unsigned int, MessageIdentifier const&, MessageData&)
    #2 0x00000104f072bc in GameObject::SendMessageAny(MessageIdentifier const&, MessageData&)
    #3 0x000001053a2524 in Transform::BroadcastMessageAny(MessageIdentifier const&, MessageData&)
    #4 0x000001053a2554 in Transform::BroadcastMessageAny(MessageIdentifier const&, MessageData&)
    #5 0x000001053a2554 in Transform::BroadcastMessageAny(MessageIdentifier const&, MessageData&)
    #6 0x00000105abe064 in UI::Canvas::WillDestroyComponent()
    #7 0x00000104f036cc in GameObject::WillDestroyGameObject()
    #8 0x00000105216efc in PreDestroyRecursive(GameObject&, unsigned long*)
    #9 0x00000105216f64 in PreDestroyRecursive(GameObject&, unsigned long*)
    #10 0x00000105216f64 in PreDestroyRecursive(GameObject&, unsigned long*)
    #11 0x00000105217a4c in DestroyObjectHighLevel_Internal(Object*, bool)
    #12 0x00000105214d74 in DestroyObjectHighLevel(Object*, bool)
    #13 0x000001052274b0 in DestroyWorldObjects(dynamic_array<int, 0ul> const&)

    They all stopped after I rolled back to unity 2021.3.5f1.

    Once more new bugs have been introduced to the latest LTS build. Unfortunately, this new version is still not usable for me.
     
    Last edited: Sep 16, 2022
  8. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Anyone tested this in 2021.3.10 that can report back?
    Thanks!
     
  9. Vincent454

    Vincent454

    Joined:
    Oct 26, 2014
    Posts:
    167
    I'm on 2021.3.9 and have had no problems with the ui anymore personally
     
    JudahMantell likes this.
  10. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Awesome, thanks for the update. Hopefully things work fine in the latest one too!
     
    Vincent454 likes this.
  11. ltomov

    ltomov

    Joined:
    Aug 3, 2017
    Posts:
    96
    Both 2021.3.9 and 2021.3.10 work fine in my case.
     
  12. Chunikus

    Chunikus

    Joined:
    Sep 5, 2020
    Posts:
    28
    I've had this bug in 2021.3.6f1 and it seems fine in 2021.3.10f1
     
  13. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    705
    I lost track of how many versions of Unity I downloaded last night in the 2021.3 range and so far None of them have uGUI working 100% and each has a slightly different flavour of something going wrong.

    Its an utter joke for what is supposed to be an LTS version of the engine.

    What I am seeing is the drawing order can be fixed in some versions but in the versions that draw correctly I'm seeing issues with scrolling not working properly.

    .10 and .11 both have drawing order issues for me
     
  14. sejton

    sejton

    Joined:
    Dec 3, 2012
    Posts:
    7
    2021.3.11f1 has the issue for me
     
  15. doseon

    doseon

    Joined:
    Mar 17, 2021
    Posts:
    39
    Reoccurring in 2021.3.11f1 version.
     
  16. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Unity 20221.3.11 crashes when enabling a GO with a canvas with override sorting.... Is the problem related?
     
    ArthurAulicino likes this.
  17. downstroypvp

    downstroypvp

    Joined:
    May 30, 2016
    Posts:
    40
    I am facing the same issue as first post on 2021.3.9. UI is displayed in wrong hierarchical order. The first canvas in the hierarchy seems to be drawn last (and is above all the other). However I modify my prefab, this canvas is always drawn first.

    All my canvases are in default layer, sort order 0. I never has this happen on 2020.

    EDIT: It looks like it was because I had several root canvases. I assumed that the draw order of those would depend on their hierarchy, but it appears that no.
     
    Last edited: Nov 15, 2022
  18. EarMaster

    EarMaster

    Joined:
    Mar 7, 2013
    Posts:
    39
    Anyone found a way around this? My UI sorting is all over the place. I have only one Canvas but elements that are higher in the hierarchy tree appear in front of elements lower in the hierarchy tree.
     
  19. Cam_Fox

    Cam_Fox

    Joined:
    Nov 23, 2018
    Posts:
    29

    Sorry to necro this thread, however I encountered the same problem in another unity version and thought I could add to the discussion. I expect this bug actually affects ALL unity project versions, if the root cause is what it appears.

    Bug
    I have an ancient project that was stuck in Unity 2018.4.14f1 that I recently upgraded to 2020.3.24f1. At runtime in the editor, I'm finding random Canvas components with "<unknown layer>" as their sort layer, which breaks all kinds of things. This is only a problem for canvases that have Override Sorting checked, though a debug script I made confirms other canvases also default to "<unknown layer>" in Awake() but are then able to infer their correct layer from a parent Canvas.

    To reiterate, it's specifically the canvases with Override Sorting checked that are getting sort layer assigned to "<unknown layer>" that break my UI in weird ways.

    Cause
    The cause appears to be mismatched layer id's from the original project that didn't carry over to the new project. These stale id's are saved permanently in the prefab data.

    In both the 2018 project and the 2020 project, I have sort layers named "UI Overlays", however the old layer id (-1341968567) is different than the new layer id (2031558239). I can verify this by opening the prefab file in visual studio and looking up m_SortingLayerID.

    Unchecking and rechecking Override Sorting on Canvas and saving the prefab DOES NOT reset the bad id. Removing and re-adding the stale Canvas component resets the ID to 0, but it then sorts the canvas onto the Default layer at runtime, which is also incorrect since the parent canvas sorts onto UI Overlays. I'm guessing Unity's internal sorting code prefers to look up the sort layer by the (stale) integer id rather than the string layer name, which should match in both projects.

    Solution
    The solution is to attach a Sorting Group component alongside the override Canvas as described in the quoted post, above. (Thank you @Schneider21 !) For sanity, ensure the Sorting Group sort order matches the override Canvas sort order so both components share the same numbers.

    I had to attach a validation script to all gameobjects with Canvas components, and use Debug.LogError to alert myself if (canvas.overrideSorting && canvas.sortingLayerName == "<unknown layer>"), because it's too difficult to discover this subtle bug at runtime until I happen to notice a broken UI.
     
    andylukito97, Braza and Schneider21 like this.