mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 06:30:19 +00:00
Expose a pointer of EventLoopProxy to process custom messages (#674)
This commit is contained in:
parent
b03d8da9bb
commit
f66a72563e
1 changed files with 8 additions and 0 deletions
|
@ -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
|
||||
|
@ -134,6 +137,11 @@ pub fn winit_runner(mut app: App) {
|
|||
let mut create_window_event_reader = EventReader::<CreateWindow>::default();
|
||||
let mut app_exit_event_reader = EventReader::<AppExit>::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,
|
||||
|
|
Loading…
Reference in a new issue