Skip to content
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

Multi-window support in quick plugins #156

Open
griffenliu opened this issue Oct 19, 2023 · 5 comments
Open

Multi-window support in quick plugins #156

griffenliu opened this issue Oct 19, 2023 · 5 comments

Comments

@griffenliu
Copy link

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

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

@Xeudodev
Copy link

This feature would be great imo!

@jakobhellermann jakobhellermann changed the title Multi-window support. Multi-window support in quick plugins Nov 5, 2023
@johanhelsing
Copy link
Contributor

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants