-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add a gizmo-based overlay to show UI node outlines (Adopted) #11237
Conversation
IMO no, this doesn't justify the complexity here (for now). Just make sure there's a good way for users to toggle it from their own code.
Definitely belongs in bevy_ui for now. If the plans regarding a bevy_debug_tools first-party crate come to fruition, this is another prime candidate for inclusion and should be moved there. |
Agreed, for now I'll remove the key binding, the user can easily enough enable or disable by setting DebugOptions::enabled = true / false. |
It might be worth adding a toggle so that only Reason for this: some Apps will create all their UI elements upfront under separate root nodes, then just show/hide these elements by changing the root node Visibility settings. In this scenario, users could potentially see 100s of overlaid outlines which would make this new feature harder to use |
Added this, for now, It will hide the outlines of anything that is not visible judging by ViewVisibility component, let me know if you guys think that there is another better approach in this case |
Remembered about UiScale, I'll have a little look at it another hour, but this is a error so I'll throw this in draft until I fix it |
With this fixed, only thing that matters for now is adding some docs, I'm not very good at this, will try tomorrow 👍 |
You added a new feature but didn't update the readme. Please run |
I removed the feature from top level features. Added |
Hmm, if we add a dev-dependency on This may still be better, as it prompts users that the flag exists though. |
That does work, but that can be strange. If for some reason you enable the feature, the dev_tools plugin will be auto Added by the feature in |
Yeah, I think this is better. Thanks for checking! |
# Objective - This is an adopted version of #10420 - The objective is to help debugging the Ui layout tree with helpful outlines, that can be easily enabled/disabled ## Solution - Like #10420, the solution is using the bevy_gizmos in outlining the nodes --- ## Changelog ### Added - Added debug_overlay mod to `bevy_dev_tools` - Added bevy_ui_debug feature to `bevy_dev_tools` ## How to use - The user must use `bevy_dev_tools` feature in TOML - The user must use the plugin UiDebugPlugin, that can be found on `bevy::dev_tools::debug_overlay` - Finally, to enable the function, the user must set `UiDebugOptions::enabled` to true Someone can easily toggle the function with something like: ```rust fn toggle_overlay(input: Res<ButtonInput<KeyCode>>, options: ResMut<UiDebugOptions>) { if input.just_pressed(KeyCode::Space) { // The toggle method will enable if disabled and disable if enabled options.toggle(); } } ``` Note that this feature can be disabled from dev_tools, as its in fact behind a default feature there, being the feature bevy_ui_debug. # Limitations Currently, due to limitations with gizmos itself, it's not possible to support this feature to more the one window, so this tool is limited to the primary window only. # Showcase ![image](https://github.com/bevyengine/bevy/assets/126117294/ce9d70e6-0a57-4fa9-9753-ff5a9d82c009) Ui example with debug_overlay enabled ![image](https://github.com/bevyengine/bevy/assets/126117294/e945015c-5bab-4d7f-9273-472aabaf25a9) And disabled --------- Co-authored-by: Nicola Papale <[email protected]> Co-authored-by: Pablo Reinhardt <[email protected]> Co-authored-by: Alice Cecile <[email protected]>
You added a new example but didn't add metadata for it. Please update the root Cargo.toml file. |
Third time in this PR. |
@alice-i-cecile Should be alright now, main Ci passed. |
# Objective #11237 added some new text to the UI example. Unlike the other text sharing the same container just above, this new text has no padding and straddles the edge of the screen. ## Solution Move the padding to the container, and add `row_gap` so nodes placed in the container get some vertical separation as well. Before / After <img width="320" alt="12567-before (1)" src="https://github.com/bevyengine/bevy/assets/200550/de0aa142-c715-4c57-b607-d1bdc5d20a01"> <img width="320" alt="12567-after" src="https://github.com/bevyengine/bevy/assets/200550/70b5c9db-9cb2-4f92-88b0-83590ea838b0">
Objective
Solution
Changelog
Added
bevy_dev_tools
bevy_dev_tools
How to use
bevy_dev_tools
feature in TOMLbevy::dev_tools::debug_overlay
UiDebugOptions::enabled
to trueSomeone can easily toggle the function with something like:
Note that this feature can be disabled from dev_tools, as its in fact behind a default feature there, being the feature bevy_ui_debug.
Limitations
Currently, due to limitations with gizmos itself, it's not possible to support this feature to more the one window, so this tool is limited to the primary window only.
Showcase
Ui example with debug_overlay enabled
And disabled