diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index f95544cdcd949..20a482a278248 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -22,6 +22,9 @@ use winit::{ #[derive(Default)] pub struct WinitPlugin; +#[derive(Debug)] +pub struct EventLoopProxyPtr(pub usize); + impl Plugin for WinitPlugin { fn build(&self, app: &mut AppBuilder) { app @@ -81,6 +84,11 @@ pub fn winit_runner(mut app: App) { let mut create_window_event_reader = EventReader::::default(); let mut app_exit_event_reader = EventReader::::default(); + app.resources + .insert_thread_local(EventLoopProxyPtr( + Box::into_raw(Box::new(event_loop.create_proxy())) as usize, + )); + handle_create_window_events( &mut app.resources, &event_loop,