Open alice-i-cecile opened 2 years ago
For headless testing of UI, see the example in this pull request for adding headless windows: #3835
Just started learning Bevy and Rust, where should I start for this issue?
Just started learning Bevy and Rust, where should I start for this issue?
Thanks @YourAlly :) So, the steps I would take are:
https://doc.rust-lang.org/cargo/reference/features.html is a useful learning resource here; you can see how to use feature flags to conditionally enable compilation of certain code segments.
Feel free to check in with me or report back on this thread if you get stuck.
With my PR, the example provided simply compiles. I am not sure what UI functionalities must work in a headless mode, hence provided no tests. Disregard, what I did was horribly wrong.
The simple UI test provided in #3835 (check if button is centered in a window without a window) passes with rendering disabled by preventing
widget::text_system
widget::image_node_system
from loading when UIPlugin
is added. These systems heavily depend on textures: Res<Assets<Image>>
; that is the reason TextPlugin
will not work without rendering, too.
I bet those Res<Assets<Image>>
can be Option
s to allow for "imaginary" UI text and images that still can be tested for correct positioning, but simply are not rendered. If so, is this the correct way of solving the issue?
I bet those Res<Assets
> can be Options to allow for "imaginary" UI text and images that still can be tested for correct positioning, but simply are not rendered. If so, is this the correct way of solving the issue?
Yep, that seems promising!
Not just without rendering, but it would be great to be able to use UI with a custom non-wgpu based renderer.
That way projects can use bevy_ui and bevy_ui-based crates without any logic, styling, event handling, etc changes, and without needing to write their own UI and layout system, but still being able to use their own renderer and just write a simple system to query the list of finalized nodes to build draw calls for.
Bevy version
0.6
What you did
What actually happened
This panic is in https://github.com/bevyengine/bevy/blob/458cb7a9e93dab3127bb99ce7bf8cfc3af18851d/crates/bevy_ui/src/render/mod.rs#L61.
Additional information
Related to #3155.
This is essential for headless integration testing of UI logic.