vladbat00 / bevy_egui

This crate provides an Egui integration for the Bevy game engine. πŸ‡ΊπŸ‡¦ Please support the Ukrainian army: https://savelife.in.ua/en/
MIT License
974 stars 252 forks source link

Bevy 0.15 - Retained render world changes #317

Closed ptsd closed 2 days ago

ptsd commented 1 month ago

As of bevy 0.15 there are some changes to the ExtractComponent stuff that will require some rework of EguiNode and EguiRenderToTextureNode.

Relevant migration doc

I don't have enough understanding of the bevy pipeline to fully grok the nuance, but essentialy this query:

impl Node for EguiNode {
    fn update(&mut self, world: &mut World) {
...
        let mut render_target_query =
            world.query::<(&EguiSettings, &RenderTargetSize, &mut EguiRenderOutput)>();

        let Ok((egui_settings, window_size, mut render_output)) =
            render_target_query.get_mut(world, self.window_entity)
        else {
            return;
        };

will now never match anything and thus never run the Node logic for painting egui.

Instead something must match up the two worlds eg:

if self.main_world_entity.is_none() {
    for (entity, main_entity) in world.query::<(Entity, &MainEntity)>().iter(world) {
        if main_entity.id() == self.window_entity {
            self.main_world_entity = Some(entity.clone());
            break;
        }
    }
}

let Some(found_main_entity) = self.main_world_entity else {
    return;
};

...

render_target_query.get_mut(world, found_main_entity)

I am 100% sure there is a far better way to achieve this, but a POC that works for at least non render_to_texture stuff is available at https://github.com/ptsd/bevy_egui/tree/bevy-0.15.

Hope that helps πŸ˜ƒ

vladbat00 commented 2 days ago

The update with Bevy 0.15 is now released. Thank you!