Plonq / bevy_panorbit_camera

A simple pan and orbit camera for the Bevy game engine
Apache License 2.0
186 stars 36 forks source link

egui feature will not work if default plugin sets exit_condition #14

Closed ybyygu closed 1 year ago

ybyygu commented 1 year ago

Thank you for your great work and continuous improvement! I find bevy_egui to be a great feature that I really needed. However, I noticed that it doesn’t work as expected when I set the exit_condition in DefaultPlugins.

Relevant code snippets:

let default_plugin = DefaultPlugins.set(WindowPlugin {
    // FIXME: it will work if comment below line
    exit_condition: bevy::window::ExitCondition::OnPrimaryClosed,
    ..default()
});

App::new()
    .add_plugins(default_plugin)
    .add_plugin(PanOrbitCameraPlugin)
    .add_plugin(WorldInspectorPlugin::default())
    .add_startup_system(setup)
    .run();`

To reproduce this bug

  1. Changes I made in my fork: https://github.com/Plonq/bevy_panorbit_camera/compare/master...ybyygu:bevy_panorbit_camera-egui-bug:master
  2. run

    cargo run --example egui --features bevy_egui

Plonq commented 1 year ago

Hi! Thanks for the kind words, and thanks for the bug report. I've got a fix for this incoming.

Plonq commented 1 year ago

This should be fixed in v0.4.2

ybyygu commented 1 year ago

I appreciate your quick solution to the problem. It works as expected. However, there is a catch: the order of plugins matters. It doesn't work if PanOrbitCameraPlugin comes before WorldInspectorPlugin.

App::new()
    .add_plugins(default_plugin)
    // FIXME: the plugin order matters
    .add_plugin(PanOrbitCameraPlugin)
    .add_plugin(WorldInspectorPlugin::default())
    .add_startup_system(setup)
    .run();

Check my codes to reproduce: https://github.com/Plonq/bevy_panorbit_camera/compare/master...ybyygu:bevy_panorbit_camera-egui-bug:master

Plonq commented 1 year ago

Released a fix for the plugin ordering issue. Hopefully there are no more issues now, but if there are let me know! Thanks for reporting!