jakobhellermann / bevy-inspector-egui

Inspector plugin for the bevy game engine
Apache License 2.0
1.1k stars 164 forks source link

Multi-window support in `quick` plugins #156

Open griffenliu opened 8 months ago

griffenliu commented 8 months ago

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?

jakobhellermann commented 8 months ago

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 commented 8 months ago

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

griffenliu commented 8 months ago

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

Xeudodev commented 8 months ago

This feature would be great imo!

johanhelsing commented 7 months ago

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)