Open
Description
Bevy version
- bevy 0.14
- current commit (at time of posting)
bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "0685d2d" }
[Optional] Relevant system information
- window 10
- cargo 1.79.0 (ffa9cf99a 2024-06-03)
AdapterInfo { name: "NVIDIA GeForce GTX 1080", vendor: 4318, device: 7040, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "551.86", backend: Vulkan }
What you did
I can display gizmos just fine, but when I do it from a system that was triggered by app.observe, it silently fails.
Minimal example:
use bevy::{
color::palettes::css::{BLUE, RED},
prelude::*,
};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, init_camera)
// drawing a blue gizmo works as expected
.add_systems(Update, regular_gizmo)
// we trigger the DrawRedGizmo event on each frame
.add_systems(Update, trigger_red_gizmo)
// we try to draw a gizmo from this callback
.observe(on_red_gizmo_triggered)
.run();
}
#[derive(Event)]
struct DrawRedGizmo;
fn init_camera(mut cmd: Commands) {
cmd.spawn(Camera2dBundle::default());
}
fn regular_gizmo(mut gizmos: Gizmos) {
gizmos.circle_2d(Vec2::new(-50.0, 0.0), 40.0, BLUE);
}
fn trigger_red_gizmo(mut cmd: Commands) {
cmd.trigger(DrawRedGizmo);
}
fn on_red_gizmo_triggered(_trigger: Trigger<DrawRedGizmo>, mut gizmos: Gizmos) {
// that gizmo isn't shown.
gizmos.circle_2d(Vec2::new(50.0, 0.0), 40.0, RED);
}
You can check the repository I made there:
https://github.com/cark/bevy-gizmo-bug
It contains a branch for bevy 0.14 and one for the current (at time of this post) bevy commit.
What went wrong
- what were you expecting?
- I was expecting to see a red and a blue gizmo
- what actually happened?
- only the blue gizmo was visible