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

Bug Nested canvas with override sorting - broken input?

Discussion in 'UGUI & TextMesh Pro' started by tduriga, Jan 17, 2023.

  1. tduriga


    Dec 9, 2015
    I have the scene with the following hierarchy:
    The Canvas2 has Override Sorting enabled with the same Sorting Layer/Order as the parent Canvas. When I enter the play mode in Unity, the render and input order is different than the object hierarchy, the Canvas2 is rendered first (in the back) and then are the Button and Image1-3. I added EventTrigger OnClick event on the Image inside Canvas2 to print log to console, the same thing with the Button - Everything seems to be working normally, the Images1-3 block the input and the Button and Event inside Canvas2 are working as expected - the input respect the render order. (Left Image)

    When I disable Override Sorting on Canvas2, then everything works as expected again, Button is now behind the Canvas2 and the render order is the same as the hierarchy. (Middle image)

    But when I enable the Override Sorting on the Canvas2 back, the Canvas2 is rendered in front of everything and the input order is broken completely. The Canvas2 is rendered in the front, but the Images1-3 are blocking the input and I can click on the Button (I see the click log in console). The button is rendered behind the Canvas2 also in the hierarchy is above the Canvas2 so I would expect that the input is blocked, but it seems that the order of inputs is the same as with Sorting Order disabled. (Right Image)


    Is this bug or am I missing something? Why is the child canvas rendered behind everything after the scene is launched and when the Override Sorting is turned Off then On it jumps in the front? I tested it in 2021.3.16 and 2022.2.2 with the same results. The only fix to block clicks is to add second Image inside Canvas2, the canvas is still rendered in the front, but at least the input is blocked. I noticed this behaviour with my game when the click went throught the dialogs so I tried to replicate it inside clean project and it works the same. I also created the bug report with ID: IN-29121

    Thanks for any help.