diff --git a/examples/render_to_image_widget.rs b/examples/render_to_image_widget.rs index 7f9a60fd4..1d24862df 100644 --- a/examples/render_to_image_widget.rs +++ b/examples/render_to_image_widget.rs @@ -69,7 +69,7 @@ fn setup( egui_user_textures.add_image(image_handle.clone()); commands.insert_resource(CubePreviewImage(image_handle.clone())); - let cube_handle = meshes.add(Mesh::from(shape::Cube { size: 4.0 })); + let cube_handle = meshes.add(Mesh::from(Cuboid::new(4.0, 4.0, 4.0))); let default_material = StandardMaterial { base_color: Color::rgb(0.8, 0.7, 0.6), reflectance: 0.02, @@ -115,7 +115,7 @@ fn setup( .insert(preview_pass_layer); let cube_size = 4.0; - let cube_handle = meshes.add(Mesh::from(shape::Box::new(cube_size, cube_size, cube_size))); + let cube_handle = meshes.add(Mesh::from(Cuboid::new(cube_size, cube_size, cube_size))); let main_material_handle = materials.add(default_material); diff --git a/examples/side_panel.rs b/examples/side_panel.rs index 45ad2968f..b65649a19 100644 --- a/examples/side_panel.rs +++ b/examples/side_panel.rs @@ -75,15 +75,12 @@ fn setup_system( mut materials: ResMut>, ) { commands.spawn(PbrBundle { - mesh: meshes.add(Mesh::from(shape::Plane { - size: 5.0, - subdivisions: 0, - })), + mesh: meshes.add(Mesh::from(Plane3d::default().mesh().size(5.0, 5.0))), material: materials.add(Color::rgb(0.3, 0.5, 0.3)), ..Default::default() }); commands.spawn(PbrBundle { - mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })), + mesh: meshes.add(Mesh::from(Cuboid::new(1.0, 1.0, 1.0))), material: materials.add(Color::rgb(0.8, 0.7, 0.6)), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..Default::default() diff --git a/src/systems.rs b/src/systems.rs index 42dbb4cce..d0c9ee5f5 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -9,7 +9,7 @@ use bevy::{ system::{Local, Res, ResMut, SystemParam}, }, input::{ - keyboard::{KeyCode, KeyboardInput}, + keyboard::{Key, KeyCode, KeyboardInput}, mouse::{MouseButton, MouseButtonInput, MouseScrollUnit, MouseWheel}, touch::TouchInput, ButtonInput, ButtonState, @@ -244,7 +244,7 @@ pub fn process_input_system( }) { for ev in input_events.ev_keyboard_input.read() { - if let Some(key) = bevy_to_egui_key(ev.key_code) { + if let Some(key) = bevy_to_egui_key(&ev.logical_key) { let pressed = match ev.state { ButtonState::Pressed => true, ButtonState::Released => false, @@ -524,60 +524,62 @@ fn egui_to_winit_cursor_icon(cursor_icon: egui::CursorIcon) -> Option Option { - let key = match key_code { - KeyCode::ArrowDown => egui::Key::ArrowDown, - KeyCode::ArrowLeft => egui::Key::ArrowLeft, - KeyCode::ArrowRight => egui::Key::ArrowRight, - KeyCode::ArrowUp => egui::Key::ArrowUp, - KeyCode::Escape => egui::Key::Escape, - KeyCode::Tab => egui::Key::Tab, - KeyCode::Backspace => egui::Key::Backspace, - KeyCode::Enter => egui::Key::Enter, - KeyCode::NumpadEnter => egui::Key::Enter, - KeyCode::Space => egui::Key::Space, - KeyCode::Insert => egui::Key::Insert, - KeyCode::Delete => egui::Key::Delete, - KeyCode::Home => egui::Key::Home, - KeyCode::End => egui::Key::End, - KeyCode::PageUp => egui::Key::PageUp, - KeyCode::PageDown => egui::Key::PageDown, - KeyCode::Numpad0 | KeyCode::Digit0 => egui::Key::Num0, - KeyCode::Numpad1 | KeyCode::Digit1 => egui::Key::Num1, - KeyCode::Numpad2 | KeyCode::Digit2 => egui::Key::Num2, - KeyCode::Numpad3 | KeyCode::Digit3 => egui::Key::Num3, - KeyCode::Numpad4 | KeyCode::Digit4 => egui::Key::Num4, - KeyCode::Numpad5 | KeyCode::Digit5 => egui::Key::Num5, - KeyCode::Numpad6 | KeyCode::Digit6 => egui::Key::Num6, - KeyCode::Numpad7 | KeyCode::Digit7 => egui::Key::Num7, - KeyCode::Numpad8 | KeyCode::Digit8 => egui::Key::Num8, - KeyCode::Numpad9 | KeyCode::Digit9 => egui::Key::Num9, - KeyCode::KeyA => egui::Key::A, - KeyCode::KeyB => egui::Key::B, - KeyCode::KeyC => egui::Key::C, - KeyCode::KeyD => egui::Key::D, - KeyCode::KeyE => egui::Key::E, - KeyCode::KeyF => egui::Key::F, - KeyCode::KeyG => egui::Key::G, - KeyCode::KeyH => egui::Key::H, - KeyCode::KeyI => egui::Key::I, - KeyCode::KeyJ => egui::Key::J, - KeyCode::KeyK => egui::Key::K, - KeyCode::KeyL => egui::Key::L, - KeyCode::KeyM => egui::Key::M, - KeyCode::KeyN => egui::Key::N, - KeyCode::KeyO => egui::Key::O, - KeyCode::KeyP => egui::Key::P, - KeyCode::KeyQ => egui::Key::Q, - KeyCode::KeyR => egui::Key::R, - KeyCode::KeyS => egui::Key::S, - KeyCode::KeyT => egui::Key::T, - KeyCode::KeyU => egui::Key::U, - KeyCode::KeyV => egui::Key::V, - KeyCode::KeyW => egui::Key::W, - KeyCode::KeyX => egui::Key::X, - KeyCode::KeyY => egui::Key::Y, - KeyCode::KeyZ => egui::Key::Z, +fn bevy_to_egui_key(key: &Key) -> Option { + let key = match key { + Key::ArrowDown => egui::Key::ArrowDown, + Key::ArrowLeft => egui::Key::ArrowLeft, + Key::ArrowRight => egui::Key::ArrowRight, + Key::ArrowUp => egui::Key::ArrowUp, + Key::Escape => egui::Key::Escape, + Key::Tab => egui::Key::Tab, + Key::Backspace => egui::Key::Backspace, + Key::Enter => egui::Key::Enter, + Key::Space => egui::Key::Space, + Key::Insert => egui::Key::Insert, + Key::Delete => egui::Key::Delete, + Key::Home => egui::Key::Home, + Key::End => egui::Key::End, + Key::PageUp => egui::Key::PageUp, + Key::PageDown => egui::Key::PageDown, + Key::Character(c) => match c.to_string().to_lowercase().as_str() { + "0" => egui::Key::Num0, + "1" => egui::Key::Num1, + "2" => egui::Key::Num2, + "3" => egui::Key::Num3, + "4" => egui::Key::Num4, + "5" => egui::Key::Num5, + "6" => egui::Key::Num6, + "7" => egui::Key::Num7, + "8" => egui::Key::Num8, + "9" => egui::Key::Num9, + "a" => egui::Key::A, + "b" => egui::Key::B, + "c" => egui::Key::C, + "d" => egui::Key::D, + "e" => egui::Key::E, + "f" => egui::Key::F, + "g" => egui::Key::G, + "h" => egui::Key::H, + "i" => egui::Key::I, + "j" => egui::Key::J, + "k" => egui::Key::K, + "l" => egui::Key::L, + "m" => egui::Key::M, + "n" => egui::Key::N, + "o" => egui::Key::O, + "p" => egui::Key::P, + "q" => egui::Key::Q, + "r" => egui::Key::R, + "s" => egui::Key::S, + "t" => egui::Key::T, + "u" => egui::Key::U, + "v" => egui::Key::V, + "w" => egui::Key::W, + "x" => egui::Key::X, + "y" => egui::Key::Y, + "z" => egui::Key::Z, + _ => return None, + }, _ => return None, }; Some(key)