Skip to content

UI z-ordering fix #19691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

UI z-ordering fix #19691

wants to merge 10 commits into from

Conversation

ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Jun 17, 2025

Objective

During the migration to required components a lot of things were changed around and somehow the draw order for some UI elements ended up depending on the system ordering in RenderSystems::Queue, which can sometimes result in the elements being drawn in the wrong order.

Fixes #19674

Solution

  • Added some more stack_z_offsets constants and used them to enforce an explicit ordering.
  • Removed the stack_index: u32 field from ExtractedUiNodes and replaced it with a z_order: f32 field.

These changes should fix all the ordering problems.

Testing

I added a nine-patched bordered node with a navy background color to the slice section of the testbed_ui example.
The border should always be drawn above the background color.

Added `BORDER` and `BORDER_GRADIENT` constants to `stack_z_offsets.

Added `z_order: f32` field to `ExtractedUiNode`, this replaces `stack_index`.
@ickshonpe ickshonpe added C-Bug An unexpected or incorrect behavior A-UI Graphical user interfaces, styles, layouts, and widgets M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered A-Rendering Drawing game state to the screen labels Jun 17, 2025
@alice-i-cecile alice-i-cecile added this to the 0.17 milestone Jun 17, 2025
@alice-i-cecile alice-i-cecile added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Jun 19, 2025
@ickshonpe ickshonpe added the D-Straightforward Simple bug fixes and API improvements, docs, test and examples label Jun 19, 2025
@ickshonpe ickshonpe added the M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Sliced images not working with BackgroundColor when using limited features enabled.
2 participants