Skip to content
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

Draw the UI debug overlay using the UI renderer #16693

Merged
merged 17 commits into from
Dec 11, 2024

Conversation

ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Dec 6, 2024

Objective

Draw the UI debug overlay using the UI renderer.

Significantly simpler and easier to use than bevy_dev_tools::ui_debug_overlay which uses bevy_gizmos.

  • Supports multiple windows and UI rendered to texture.
  • Draws rounded debug rects for rounded UI nodes.

Fixes #16666

Solution

Removed the ui_debug_overlay module from bevy_dev_tools.

Added a bevy_ui_debug feature gate.

Draw the UI debug overlay using the UI renderer.
Adds a new module bevy_ui::render::debug_overlay.

The debug overlay extraction function queries for the existing UI layout and then adds a border around each UI node with u32::MAX / 2 added to each stack index so it's drawn on top.

There is a UiDebugOptions resource that can be used to enable or disable the debug overlay and set the line width.

Testing

The testbed_ui example has been changed to use the new debug overlay:

cargo run --example testbed_ui --features bevy_ui_debug

Press Space to toggle the debug overlay on and off.


Showcase

testbed-ui-new-debug

Migration Guide

The ui_debug_overlay module has been removed from bevy_dev_tools.
There is a new debug overlay implemented using the bevy_ui renderer. To use it, enable the bevy_ui_debug feature and set the enable field of the UiDebugOptions resource to true.

* Added `UiDebugOptions` resource that can be used to enable or disable the debug overlay and set the line width.
* New `extract_debug_overlay` system that extracts the node geometry for rendering.
@ickshonpe ickshonpe changed the title Alternative UI debug overlay rendering Draw the UI debug overlay using the UI renderer Dec 6, 2024
@JMS55
Copy link
Contributor

JMS55 commented Dec 6, 2024

Can we get a rounded node in the example to ensure we don't break this later?

@ickshonpe
Copy link
Contributor Author

ickshonpe commented Dec 6, 2024

Can we get a rounded node in the example to ensure we don't break this later?

The rotated bevy logo in the bottom left has a rounded debug outline (the blue outline).

@JMS55
Copy link
Contributor

JMS55 commented Dec 6, 2024

Oh I missed that 😅

@alice-i-cecile alice-i-cecile added A-UI Graphical user interfaces, styles, layouts, and widgets M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide A-Dev-Tools Tools used to debug Bevy applications. S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Dec 7, 2024
Copy link
Contributor

github-actions bot commented Dec 7, 2024

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Could you add some context on what users should update when this change get released in a new version of Bevy?
It will be used to help writing the migration guide for the version. Putting it after a ## Migration Guide will help it get automatically picked up by our tooling.

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a much simpler and more reliable way to do this: I really prefer it. That said, we should clean up and remove the old approach in this PR, and write a migration guide.

I don't feel strongly about "where should this live": bevy_dev_tools is in a weird spot currently, but if this lives in bevy_ui we should probably feature flag it.

@ickshonpe
Copy link
Contributor Author

ickshonpe commented Dec 7, 2024

This is a much simpler and more reliable way to do this: I really prefer it. That said, we should clean up and remove the old approach in this PR, and write a migration guide.

I don't feel strongly about "where should this live": bevy_dev_tools is in a weird spot currently, but if this lives in bevy_ui we should probably feature flag it.

It seems to me that bevy_dev_tools should be more for more general profiling and testing features which are going to be useful for any Bevy application. The UI debug overlay is UI specific so it belongs in the UI crate imo.

Copy link
Contributor

github-actions bot commented Dec 7, 2024

You added a new feature but didn't update the readme. Please run cargo run -p build-templated-pages -- update features to update it, and commit the file change.

Copy link
Contributor

github-actions bot commented Dec 7, 2024

You added a new feature but didn't update the readme. Please run cargo run -p build-templated-pages -- update features to update it, and commit the file change.

@ickshonpe ickshonpe added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Dec 7, 2024
@ickshonpe ickshonpe removed the S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged label Dec 7, 2024
@JeanMertz
Copy link
Contributor

I backported and tested this on the 0.15 release. Works beautifully.

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Dec 10, 2024
@alice-i-cecile
Copy link
Member

@ickshonpe I'm going to count that as a second approval. Ping me when this is up to date with main please :)

@ickshonpe
Copy link
Contributor Author

ickshonpe commented Dec 10, 2024

@alice-i-cecile should be ready now. We're just ignoring the failing check-advisories CI for the moment?

@alice-i-cecile
Copy link
Member

Yeah, it's blocked on an upstream fix :(

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 11, 2024
Merged via the queue into bevyengine:main with commit 9098973 Dec 11, 2024
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Dev-Tools Tools used to debug Bevy applications. A-UI Graphical user interfaces, styles, layouts, and widgets M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DebugUiPlugin doesn't respect scale factor properly
6 participants