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

Update to bevy 0.11 #188

Merged
merged 7 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
features: [
'',
'manage_clipboard',
'open_url',
'manage_clipboard,open_url',
]
features:
["", "manage_clipboard", "open_url", "manage_clipboard,open_url"]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -68,12 +64,15 @@ jobs:
strategy:
fail-fast: false
matrix:
features: [
'immutable_ctx',
'manage_clipboard',
'open_url',
'manage_clipboard,open_url',
]
features:
[
"immutable_ctx",
"manage_clipboard",
"open_url",
"manage_clipboard,open_url",
]
env:
RUSTFLAGS: --cfg=web_sys_unstable_apis
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand Down
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ default_fonts = ["egui/default_fonts"]
serde = ["egui/serde"]

[dependencies]
bevy = { version = "0.10", default-features = false, features = ["bevy_render", "bevy_asset"] }
bevy = { version = "0.11", default-features = false, features = [
"bevy_render",
"bevy_asset",
] }
egui = { version = "0.21.0", default-features = false, features = ["bytemuck"] }
webbrowser = { version = "0.8.2", optional = true }

Expand All @@ -33,7 +36,7 @@ thread_local = { version = "1.1.0", optional = true }
[dev-dependencies]
once_cell = "1.16.0"
version-sync = "0.9.4"
bevy = { version = "0.10", default-features = false, features = [
bevy = { version = "0.11", default-features = false, features = [
"x11",
"png",
"bevy_pbr",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn main() {
.add_plugin(EguiPlugin)
// Systems that create Egui widgets should be run during the `CoreSet::Update` set,
// or after the `EguiSet::BeginFrame` system (which belongs to the `CoreSet::PreUpdate` set).
.add_system(ui_example_system)
.add_systems(Update, ui_example_system)
.run();
}

Expand Down
8 changes: 4 additions & 4 deletions examples/render_to_image_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use egui::Widget;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(EguiPlugin)
.add_startup_system(setup)
.add_system(rotator_system)
.add_system(render_to_image_example_system)
.add_plugins(EguiPlugin)
.add_systems(Startup, setup)
.add_systems(Update, rotator_system)
.add_systems(Update, render_to_image_example_system)
.run();
}

Expand Down
8 changes: 4 additions & 4 deletions examples/side_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ struct OriginalCameraTransform(Transform);
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(EguiPlugin)
.add_plugins(EguiPlugin)
.init_resource::<OccupiedScreenSpace>()
.add_startup_system(setup_system)
.add_system(ui_example_system)
.add_system(update_camera_transform_system)
.add_systems(Startup, setup_system)
.add_systems(Update, ui_example_system)
.add_systems(Update, update_camera_transform_system)
.run();
}

Expand Down
4 changes: 2 additions & 2 deletions examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use bevy_egui::{egui, EguiContexts, EguiPlugin};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(EguiPlugin)
.add_plugins(EguiPlugin)
// Systems that create Egui widgets should be run during the `CoreSet::Update` set,
// or after the `EguiSet::BeginFrame` system (which belongs to the `CoreSet::PreUpdate` set).
.add_system(ui_example_system)
.add_systems(Update, ui_example_system)
.run();
}

Expand Down
18 changes: 11 additions & 7 deletions examples/two_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ struct Images {
fn main() {
let mut app = App::new();
app.add_plugins(DefaultPlugins)
.add_plugin(EguiPlugin)
.add_plugins(EguiPlugin)
.init_resource::<SharedUiState>()
.add_startup_system(load_assets_system)
.add_startup_system(create_new_window_system)
.add_system(ui_first_window_system)
.add_system(ui_second_window_system);
.add_systems(Startup, load_assets_system)
.add_systems(Startup, create_new_window_system)
.add_systems(Update, ui_first_window_system)
.add_systems(Update, ui_second_window_system);

app.run();
}
Expand Down Expand Up @@ -69,7 +69,9 @@ fn ui_first_window_system(
mut egui_ctx: Query<&mut EguiContext, With<PrimaryWindow>>,
) {
let bevy_texture_id = egui_user_textures.add_image(images.bevy_icon.clone_weak());
let Ok(mut ctx) = egui_ctx.get_single_mut() else { return; };
let Ok(mut ctx) = egui_ctx.get_single_mut() else {
return;
};
egui::Window::new("First Window")
.vscroll(true)
.show(ctx.get_mut(), |ui| {
Expand All @@ -94,7 +96,9 @@ fn ui_second_window_system(
mut egui_ctx: Query<&mut EguiContext, Without<PrimaryWindow>>,
) {
let bevy_texture_id = egui_user_textures.add_image(images.bevy_icon.clone_weak());
let Ok(mut ctx) = egui_ctx.get_single_mut() else { return; };
let Ok(mut ctx) = egui_ctx.get_single_mut() else {
return;
};
egui::Window::new("Second Window")
.vscroll(true)
.show(ctx.get_mut(), |ui| {
Expand Down
10 changes: 5 additions & 5 deletions examples/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ fn main() {
.insert_resource(Msaa::Sample4)
.init_resource::<UiState>()
.add_plugins(DefaultPlugins)
.add_plugin(EguiPlugin)
.add_startup_system(configure_visuals_system)
.add_startup_system(configure_ui_state_system)
.add_system(update_ui_scale_factor_system)
.add_system(ui_example_system)
.add_plugins(EguiPlugin)
.add_systems(Startup, configure_visuals_system)
.add_systems(Startup, configure_ui_state_system)
.add_systems(Update, update_ui_scale_factor_system)
.add_systems(Update, ui_example_system)
.run();
}
#[derive(Default, Resource)]
Expand Down
26 changes: 16 additions & 10 deletions src/egui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ impl Node for EguiNode {
fn update(&mut self, world: &mut World) {
let mut window_sizes = world.query::<(&WindowSize, &mut EguiRenderOutput)>();

let Ok((window_size, mut render_output)) = window_sizes.get_mut(world, self.window_entity) else {
let Ok((window_size, mut render_output)) = window_sizes.get_mut(world, self.window_entity)
else {
return;
};
let window_size = *window_size;
Expand Down Expand Up @@ -316,12 +317,13 @@ impl Node for EguiNode {
return Ok(()); // No window
};

let swap_chain_texture =
if let Some(swap_chain_texture) = extracted_window.swap_chain_texture.as_ref() {
swap_chain_texture
} else {
return Ok(()); // No swapchain texture
};
let swap_chain_texture_view = if let Some(swap_chain_texture_view) =
extracted_window.swap_chain_texture_view.as_ref()
{
swap_chain_texture_view
} else {
return Ok(()); // No swapchain texture
};

let render_queue = world.get_resource::<RenderQueue>().unwrap();

Expand All @@ -343,7 +345,7 @@ impl Node for EguiNode {
.begin_render_pass(&RenderPassDescriptor {
label: Some("egui render pass"),
color_attachments: &[Some(RenderPassColorAttachment {
view: swap_chain_texture,
view: swap_chain_texture_view,
resolve_target: None,
ops: Operations {
load: LoadOp::Load,
Expand All @@ -353,8 +355,12 @@ impl Node for EguiNode {
depth_stencil_attachment: None,
});

let Some(pipeline_id) = egui_pipelines.get(&extracted_window.entity) else { return Ok(()) };
let Some(pipeline) = pipeline_cache.get_render_pipeline(*pipeline_id) else { return Ok(()) };
let Some(pipeline_id) = egui_pipelines.get(&extracted_window.entity) else {
return Ok(());
};
let Some(pipeline) = pipeline_cache.get_render_pipeline(*pipeline_id) else {
return Ok(());
};

render_pass.set_pipeline(pipeline);
render_pass.set_vertex_buffer(0, *self.vertex_buffer.as_ref().unwrap().slice(..));
Expand Down
Loading
Loading