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 1 commit
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
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 = { git = "https://github.com/bevyengine/bevy.git", branch = "main", 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 = { git = "https://github.com/bevyengine/bevy.git", branch = "main", 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
6 changes: 3 additions & 3 deletions examples/render_to_image_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ 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_systems(Startup, setup)
.add_systems(Update, rotator_system)
.add_systems(Update, render_to_image_example_system)
.run();
}

Expand Down
6 changes: 3 additions & 3 deletions examples/side_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugin(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
2 changes: 1 addition & 1 deletion examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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/two_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ fn main() {
app.add_plugins(DefaultPlugins)
.add_plugin(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
8 changes: 4 additions & 4 deletions examples/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ fn main() {
.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_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
8 changes: 4 additions & 4 deletions src/egui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ 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
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
};
Expand All @@ -343,7 +343,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 Down
62 changes: 31 additions & 31 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,24 @@ use crate::{
#[cfg(all(feature = "manage_clipboard", not(target_arch = "wasm32")))]
use arboard::Clipboard;
use bevy::{
app::{App, Plugin},
app::{App, Plugin, Last, PostUpdate, PreUpdate, PreStartup},
asset::{AssetEvent, Assets, Handle},
ecs::{
event::EventReader,
query::{QueryEntityError, WorldQuery},
schedule::apply_system_buffers,
schedule::apply_deferred,
system::{ResMut, SystemParam},
},
input::InputSystem,
log,
prelude::{
Added, Commands, Component, CoreSet, Deref, DerefMut, Entity, IntoSystemAppConfigs,
IntoSystemConfig, IntoSystemConfigs, Query, Resource, Shader, StartupSet, SystemSet, With,
Added, Commands, Component, Deref, DerefMut, Entity,
IntoSystemConfigs, Query, Resource, Shader, SystemSet, With,
Without,
},
render::{
render_resource::SpecializedRenderPipelines, texture::Image, ExtractSchedule, RenderApp,
RenderSet,
RenderSet, Render
},
utils::HashMap,
window::{PrimaryWindow, Window},
Expand Down Expand Up @@ -534,76 +534,76 @@ impl Plugin for EguiPlugin {
world.init_resource::<EguiUserTextures>();
world.init_resource::<EguiMousePosition>();

app.add_startup_systems(
app.add_systems(PreStartup,
(
setup_new_windows_system,
apply_system_buffers,
apply_deferred,
update_window_contexts_system,
)
.chain()
.in_set(EguiStartupSet::InitContexts)
.in_base_set(StartupSet::PreStartup),
.in_set(EguiStartupSet::InitContexts),
);
app.add_systems(
app.add_systems(PreUpdate,
(
setup_new_windows_system,
apply_system_buffers,
apply_deferred,
update_window_contexts_system,
)
.chain()
.in_set(EguiSet::InitContexts)
.in_base_set(CoreSet::PreUpdate),
.in_set(EguiSet::InitContexts),
);
app.add_system(
app.add_systems(PreUpdate,
process_input_system
.in_set(EguiSet::ProcessInput)
.after(InputSystem)
.after(EguiSet::InitContexts)
.in_base_set(CoreSet::PreUpdate),
.after(EguiSet::InitContexts),
);
app.add_system(
app.add_systems(PreUpdate,
begin_frame_system
.in_set(EguiSet::BeginFrame)
.after(EguiSet::ProcessInput)
.in_base_set(CoreSet::PreUpdate),
.after(EguiSet::ProcessInput),
);
app.add_system(
app.add_systems(PostUpdate,
process_output_system
.in_set(EguiSet::ProcessOutput)
.in_base_set(CoreSet::PostUpdate),
.in_set(EguiSet::ProcessOutput),
);
app.add_system(
app.add_systems(PostUpdate,
update_egui_textures_system
.after(EguiSet::ProcessOutput)
.in_base_set(CoreSet::PostUpdate),
.after(EguiSet::ProcessOutput),
);
app.add_system(free_egui_textures_system.in_base_set(CoreSet::Last));
app.add_systems(Last, free_egui_textures_system)
.add_systems(Render,
render_systems::prepare_egui_transforms_system.in_set(RenderSet::Prepare),
)
.add_systems(Render, render_systems::queue_bind_groups_system.in_set(RenderSet::Queue))
.add_systems(Render, render_systems::queue_pipelines_system.in_set(RenderSet::Queue));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those "Render" surprised me a bit.


let mut shaders = app.world.resource_mut::<Assets<Shader>>();
shaders.set_untracked(
EGUI_SHADER_HANDLE,
Shader::from_wgsl(include_str!("egui.wgsl")),
);
}

fn finish(&self, app: &mut App) {
Vrixyz marked this conversation as resolved.
Show resolved Hide resolved
if let Ok(render_app) = app.get_sub_app_mut(RenderApp) {
render_app
.init_resource::<egui_node::EguiPipeline>()
.init_resource::<SpecializedRenderPipelines<EguiPipeline>>()
.init_resource::<EguiTransforms>()
.add_systems(
.add_systems(ExtractSchedule,
(
render_systems::extract_egui_render_data_system,
render_systems::extract_egui_textures_system,
render_systems::setup_new_windows_render_system,
)
.into_configs()
.in_schedule(ExtractSchedule),
)
.add_system(
.add_systems(Render,
render_systems::prepare_egui_transforms_system.in_set(RenderSet::Prepare),
)
.add_system(render_systems::queue_bind_groups_system.in_set(RenderSet::Queue))
.add_system(render_systems::queue_pipelines_system.in_set(RenderSet::Queue));
.add_systems(Render, render_systems::queue_bind_groups_system.in_set(RenderSet::Queue))
.add_systems(Render, render_systems::queue_pipelines_system.in_set(RenderSet::Queue));
}
}
}
Expand Down
19 changes: 9 additions & 10 deletions src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ pub fn process_input_system(
};
}

let shift = input_resources.keyboard_input.pressed(KeyCode::LShift)
|| input_resources.keyboard_input.pressed(KeyCode::RShift);
let ctrl = input_resources.keyboard_input.pressed(KeyCode::LControl)
|| input_resources.keyboard_input.pressed(KeyCode::RControl);
let alt = input_resources.keyboard_input.pressed(KeyCode::LAlt)
|| input_resources.keyboard_input.pressed(KeyCode::RAlt);
let win = input_resources.keyboard_input.pressed(KeyCode::LWin)
|| input_resources.keyboard_input.pressed(KeyCode::RWin);
let shift = input_resources.keyboard_input.pressed(KeyCode::ShiftLeft)
|| input_resources.keyboard_input.pressed(KeyCode::ShiftRight);
let ctrl = input_resources.keyboard_input.pressed(KeyCode::ControlLeft)
|| input_resources.keyboard_input.pressed(KeyCode::ControlRight);
let alt = input_resources.keyboard_input.pressed(KeyCode::AltLeft)
|| input_resources.keyboard_input.pressed(KeyCode::AltRight);
let win = input_resources.keyboard_input.pressed(KeyCode::SuperLeft)
|| input_resources.keyboard_input.pressed(KeyCode::SuperRight);

let mac_cmd = if cfg!(target_os = "macos") {
win
Expand Down Expand Up @@ -143,12 +143,11 @@ pub fn process_input_system(
// that has been left.
if cursor_left_window != Some(cursor_moved.window) {
let scale_factor = egui_settings.scale_factor as f32;
let mut mouse_position: (f32, f32) = (cursor_moved.position / scale_factor).into();
let mouse_position: (f32, f32) = (cursor_moved.position / scale_factor).into();
let mut context = context_params
.contexts
.get_mut(cursor_moved.window)
.unwrap();
mouse_position.1 = context.window_size.height() / scale_factor - mouse_position.1;
Vrixyz marked this conversation as resolved.
Show resolved Hide resolved
egui_mouse_position.0 = Some((cursor_moved.window, mouse_position.into()));
context
.egui_input
Expand Down