bevy-inspector-egui icon indicating copy to clipboard operation
bevy-inspector-egui copied to clipboard

Multi-window support in `quick` plugins

Open griffenliu opened this issue 2 years ago • 5 comments

I want to implement a multi-window function, the main window shows the game, the second window shows the inspector, can you provide this support?

griffenliu avatar Oct 19 '23 09:10 griffenliu

The only thing in bevy-inspector-egui that depends on the primary window are the quick plugins, which are just ~10 lines of code each.

You can copy them and tweak them to use your preferred window.

jakobhellermann avatar Oct 19 '23 09:10 jakobhellermann

If this use case comes up a lot and can be integrated into the quick plugins without sacrificing usability in the common case I'll consider adding that as a feature

jakobhellermann avatar Oct 19 '23 09:10 jakobhellermann

Ok, thank you very much. Here is a screenshot😀 image

griffenliu avatar Oct 19 '23 09:10 griffenliu

This feature would be great imo!

Xeudodev avatar Oct 27 '23 01:10 Xeudodev

This is what I ended up doing:

        app.add_plugins(bevy_egui::EguiPlugin)
            .add_plugins(DefaultInspectorConfigPlugin)
            .add_systems(Startup, spawn_editor_window)
            .add_systems(Update, editor_ui);

fn spawn_editor_window(mut commands: Commands) {
    commands.spawn((Window::default(), EditorWindow));
}

fn editor_ui(world: &mut World) {
    let mut egui_ctx = world
        .query_filtered::<&mut EguiContext, With<EditorWindow>>()
        .single(world)
        .clone();

    egui::CentralPanel::default().show(egui_ctx.get_mut(), |ui| {
        egui::ScrollArea::vertical()
            .auto_shrink([false, false])
            .show(ui, |ui| {
                bevy_inspector::ui_for_world(world, ui);
            })
    });
}

Agree it would have been nice to have it as a quick plugin. Sometimes the regular world inspector gets in the way of gameui, or the window layout makes it difficult (e.g. when making mobile games in portrait mode)

johanhelsing avatar Nov 19 '23 14:11 johanhelsing