diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml index ee0469e651e22..9396eca5d4e20 100644 --- a/crates/bevy_internal/Cargo.toml +++ b/crates/bevy_internal/Cargo.toml @@ -68,6 +68,7 @@ serialize = [ "bevy_input/serialize", "bevy_time/serialize", "bevy_window/serialize", + "bevy_winit?/serialize", "bevy_transform/serialize", "bevy_math/serialize", "bevy_scene?/serialize", diff --git a/crates/bevy_winit/Cargo.toml b/crates/bevy_winit/Cargo.toml index 0a74391d483f6..652ccaf3e919f 100644 --- a/crates/bevy_winit/Cargo.toml +++ b/crates/bevy_winit/Cargo.toml @@ -13,6 +13,7 @@ trace = [] wayland = ["winit/wayland", "winit/wayland-csd-adwaita"] x11 = ["winit/x11"] accesskit_unix = ["accesskit_winit/accesskit_unix", "accesskit_winit/async-io"] +serialize = ["serde"] [dependencies] # bevy @@ -36,6 +37,7 @@ accesskit_winit = { version = "0.17", default-features = false, features = [ ] } approx = { version = "0.5", default-features = false } raw-window-handle = "0.6" +serde = { version = "1.0", features = ["derive"], optional = true } [target.'cfg(target_os = "android")'.dependencies] winit = { version = "0.29", default-features = false, features = [ diff --git a/crates/bevy_winit/src/winit_event.rs b/crates/bevy_winit/src/winit_event.rs index 99df2053fd2d8..9592a5e12b7f0 100644 --- a/crates/bevy_winit/src/winit_event.rs +++ b/crates/bevy_winit/src/winit_event.rs @@ -9,6 +9,8 @@ use bevy_input::{ touchpad::{TouchpadMagnify, TouchpadRotate}, }; use bevy_reflect::Reflect; +#[cfg(feature = "serialize")] +use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; use bevy_window::{ ApplicationLifetime, CursorEntered, CursorLeft, CursorMoved, FileDragAndDrop, Ime, ReceivedCharacter, RequestRedraw, WindowBackendScaleFactorChanged, WindowCloseRequested, diff --git a/examples/app/log_layers_ecs.rs b/examples/app/log_layers_ecs.rs index c8ad424184ae1..9c4ad4ee6e134 100644 --- a/examples/app/log_layers_ecs.rs +++ b/examples/app/log_layers_ecs.rs @@ -34,11 +34,11 @@ struct CapturedLogEvents(mpsc::Receiver); /// Transfers information from the [`LogEvents`] resource to [`Events`](LogEvent). fn transfer_log_events( - reciever: NonSend, + receiver: NonSend, mut log_events: EventWriter, ) { // Make sure to use `try_iter()` and not `iter()` to prevent blocking. - log_events.send_batch(reciever.try_iter()); + log_events.send_batch(receiver.try_iter()); } /// This is the [`Layer`] that we will use to capture log events and then send them to Bevy's @@ -67,7 +67,7 @@ impl Layer for CaptureLayer { } } -/// A [`Visit`](tracing::field::Visit)or that records log messages that are transfered to [`CaptureLayer`]. +/// A [`Visit`](tracing::field::Visit)or that records log messages that are transferred to [`CaptureLayer`]. struct CaptureLayerVisitor<'a>(&'a mut Option); impl tracing::field::Visit for CaptureLayerVisitor<'_> { fn record_debug(&mut self, field: &tracing::field::Field, value: &dyn std::fmt::Debug) { @@ -78,10 +78,10 @@ impl tracing::field::Visit for CaptureLayerVisitor<'_> { } } fn update_subscriber(app: &mut App, subscriber: BoxedSubscriber) -> BoxedSubscriber { - let (sender, reciever) = mpsc::channel(); + let (sender, receiver) = mpsc::channel(); let layer = CaptureLayer { sender }; - let resource = CapturedLogEvents(reciever); + let resource = CapturedLogEvents(receiver); app.insert_non_send_resource(resource); app.add_event::();