Search Issue Tracker

Not Reproducible

Votes

4

Found in

5.5.0f3

Issue ID

869475

Regression

No

After changing the canvas active state, the canvases do not display correctly according the Sort Order

uGUI

-

Reproduction steps:
1. Open the attached project;
2. Open the scene "Scene";
3. Observe the Sort Order of the gameobjects "Canvas" and "ChildPanel";
4. Enable/disable the "ChildPanel" gameobject and observe it position in Game window;
5. Enable/disable the "Canvas" gameobjects and observe it position in Game window;

Actual result: "ChildPanel" goes on top after the gameobject is enabled/disabled, although its Sort Order is lower than "Canvas" gameobject Sort Order (canvas_order.gif). When the "Canvas" is enabled/disabled, everything looks correctly.

Expected result: "ChildPanel" should always be displayed behind the "Canvas" because "ChildPanel" Sort Order is -1 and "Canvas" Sort Order is 0.

Note: the bug shows up just in the Game window. In the Scene window, everything looks correct. Also, it happens if the gameobject "ChilPanel" has added a component Canvas. If the "ChildPanel" is created like Canvas gameobject, everything works correctly.

Reproduced with: 5.3.6p4, 5.4.3f1, 5.5.0f3, 5.6.0b3
Not reproduced with: 2018.3.0a1

Comments (4)

  1. chihjendeng

    Nov 18, 2021 06:52

    It happened to me. (Unity 2021.4.32f1)
    When game object(parent) is disable and back to active. The override sorting of Canvas under this game object malfunctions. I used workaround in this post to solve my issue:

    https://answers.unity.com/questions/1351405/canvas-override-sorting-issue.html

  2. Rafael-cmk

    Sep 29, 2019 12:27

    I'm using Unity 2019.1.11f1, this bug still happens.

  3. ryo0ka

    Jun 21, 2018 04:07

    Did experience this in my project. A simple script with `OnEnable()` fixed the issue.

  4. ProudLittlePinwheel

    Jul 13, 2017 12:20

    Toggling the Canvas.overrideSorting boolean forces a redraw and which sorts the issue. Not ideal but if you implement your own gameObject enabled/disabled function in an some script then you can do the toggling when enabled manually...

    public virtual bool Active
    {
    get { return gameObject.activeInHierarchy; }
    set
    {
    gameObject.SetActive(value);
    if(value && mCanvas != null)
    {
    bool cache = mCanvas.overrideSorting;
    mCanvas.overrideSorting = false;
    mCanvas.overrideSorting = cache;
    }
    }
    }

    ... or the same kind of thing using the OnEnable()/OnDisable() callbacks.
    Not ideal but better than nothing until a proper fix.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.