https://github.com/ickshonpe/bevy-ui-debug-overlay
Improved debug overlay for Bevy UI
https://github.com/ickshonpe/bevy-ui-debug-overlay
Last synced: about 1 year ago
JSON representation
Improved debug overlay for Bevy UI
- Host: GitHub
- URL: https://github.com/ickshonpe/bevy-ui-debug-overlay
- Owner: ickshonpe
- Created: 2024-12-23T10:11:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-02T13:07:00.000Z (over 1 year ago)
- Last Synced: 2025-03-25T08:38:10.227Z (about 1 year ago)
- Language: Rust
- Size: 298 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bevy-ui-debug-overlay
Improved UI debug overlay for Bevy 0.15.
Simpler, more efficient, and easier to use than the built-in `bevy_dev_tools::ui_debug_overlay`.
* Supports multiple windows and UI rendered to texture.
* Supports UI scale factor correctly.
* Draws rounded debug rects for rounded UI nodes.

### Usage
Add the dependency to your project's `cargo.toml`:
```
bevy-ui-debug-overlay = "0.2"
```
Add the plugin to your bevy project :
```
// From the included `debug_overlay.rs` example
fn main() {
App::new()
.add_plugins((
DefaultPlugins,
UiDebugOverlayPlugin::start_enabled().with_line_width(2.),
))
.add_systems(Startup, (setup, debug_overlay_setup))
.add_systems(Update, (update_scroll_position, toggle_debug_overlay))
.run();
}
```
The debug overlay is controlled using the `UiDebugOverlay` resource:
```
fn toggle_debug_overlay(
input: Res>,
mut debug_overlay: ResMut,
mut root_node_query: Query<&mut Visibility, (With, Without)>,
) {
if input.just_pressed(KeyCode::Space) {
// The toggle method will enable the debug overlay if disabled and disable if enabled
debug_overlay.toggle();
}
if input.just_pressed(KeyCode::KeyS) {
// Toggle debug outlines for nodes with `ViewVisibility` set to false.
debug_overlay.show_hidden = !debug_overlay.show_hidden;
}
if input.just_pressed(KeyCode::KeyC) {
// Toggle outlines for clipped UI nodes.
debug_overlay.show_clipped = !debug_overlay.show_clipped;
}
if input.just_pressed(KeyCode::KeyV) {
for mut visibility in root_node_query.iter_mut() {
// Toggle the UI root node's visibility
visibility.toggle_inherited_hidden();
}
}
}
```
You can also use `UiDebugOverlay` to set the overlay's line width:
```
debug_overlay.line_width = 2.;
```
### Example
To run the example use:
```
cargo run --example debug_overlay
```
The keys to control the example's debug overlay are on listed on the left side panel.