Skip to content

UiPlugin cannot be used without rendering #3815

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
alice-i-cecile opened this issue Jan 30, 2022 · 7 comments
Open

UiPlugin cannot be used without rendering #3815

alice-i-cecile opened this issue Jan 30, 2022 · 7 comments
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior

Comments

@alice-i-cecile
Copy link
Member

Bevy version

0.6

What you did

use bevy::prelude::*;
use bevy::ui::UiPlugin;

fn main() {
    App::new()
        .add_plugins(MinimalPlugins)
        .add_plugin(UiPlugin)
        .run();
}

What actually happened

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', C:\Users\Alice\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ui-0.6.0\src\render\mod.rs:62:70

This panic is in

pub fn build_ui_render(app: &mut App) {
.

Additional information

Related to #3155.

This is essential for headless integration testing of UI logic.

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy A-UI Graphical user interfaces, styles, layouts, and widgets labels Jan 30, 2022
@Wcubed
Copy link
Contributor

Wcubed commented Feb 1, 2022

For headless testing of UI, see the example in this pull request for adding headless windows: #3835

@YourAlly
Copy link

YourAlly commented Feb 5, 2022

Just started learning Bevy and Rust, where should I start for this issue?

@alice-i-cecile
Copy link
Member Author

Just started learning Bevy and Rust, where should I start for this issue?

Thanks @YourAlly :) So, the steps I would take are:

  1. Reproduce the problem locally.
  2. Identify why this is happening (it appears that the resource is not being added).
  3. Modify the plugin such that this system is not added or compiled if the rendering feature is disabled.
  4. Verify that the problem is fixed.
  5. Open a PR with your changes.

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.

@kirusfg
Copy link
Contributor

kirusfg commented Feb 10, 2022

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.

@kirusfg
Copy link
Contributor

kirusfg commented Feb 13, 2022

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 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?

@alice-i-cecile
Copy link
Member Author

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!

@alice-i-cecile alice-i-cecile removed the D-Trivial Nice and easy! A great choice to get started with Bevy label Feb 13, 2022
@JMS55
Copy link
Contributor

JMS55 commented Aug 19, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior
Projects
None yet
5 participants