-
Notifications
You must be signed in to change notification settings - Fork 243
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
Bevy 0.10 #159
Conversation
Fix build error from missing add_systems_to_schedule
Bevy 0.10
Ci seems to complain about a mutable reference in |
I'm seeing the following warnings in the
I'd be grateful if anyone could pick up this issue. I won't have time to return to the PR until the evening. |
I've been trying to track down the In the ui example, it comes from changing the We then set We get the shapes in let full_output = ctx.end_frame();
let egui::FullOutput {
platform_output,
shapes,
textures_delta,
repaint_after,
} = full_output;
egui_render_output.shapes = shapes; I think it only shows the warning for one frame if |
examples/simple.rs
Outdated
fn ui_example_system(mut egui_ctx: Query<&mut EguiContext, With<PrimaryWindow>>) { | ||
egui::Window::new("Hello").show(egui_ctx.single_mut().get_mut(), |ui| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can it be simplified like this?
fn ui_example_system(mut egui_ctx: Query<&mut EguiContext, With<PrimaryWindow>>) { | |
egui::Window::new("Hello").show(egui_ctx.single_mut().get_mut(), |ui| { | |
fn ui_example_system(egui_ctx: Query<&EguiContext, With<PrimaryWindow>>) { | |
egui::Window::new("Hello").show(egui_ctx.single(), |ui| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only if we implement Deref
and DerefMut
for EguiContext
, giving people an interface to borrow the context immutably, which I'm hesitant to do due to the following:
Lines 247 to 256 in 7151c40
/// Even though the mutable borrow isn't necessary, as the context is wrapped into `RwLock`, | |
/// using the immutable getter is gated with the `immutable_ctx` feature. Using the immutable | |
/// borrow is discouraged as it may cause unpredictable blocking in UI systems. | |
/// | |
/// When the context is queried with `&mut EguiContext`, the Bevy scheduler is able to make | |
/// sure that the context isn't accessed concurrently and can perform other useful work | |
/// instead of busy-waiting. | |
pub fn get_mut(&mut self) -> &mut egui::Context { | |
&mut self.0 | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up introducing the EguiContexts
system param, to combine the best of both worlds: low boilerplate and mutable borrowing by default.
@DGriffin91 thanks for looking into this! That definitely saved me time investigating. It seems that I was able to fix the warning here: 7151c40. |
The PR is almost finished. I'll let people review the API changes, and tomorrow morning I'll push the last bits of the documentation fixes and make a release. |
Co-authored-by: Jakob Hellermann <jakob.hellermann@protonmail.com>
Based on #148