diff --git a/src/editor.rs b/src/editor.rs index 1869d6a..6aa2373 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -58,6 +58,7 @@ fn init_editor( fn open_editor( mut ws: Query<&mut Window, With>, + state: Res>, ) { ws.iter_mut().for_each(|mut w| { w.visible = true; @@ -66,6 +67,7 @@ fn open_editor( fn close_editor( mut ws: Query<&mut Window, With>, + state: Res>, ) { ws.iter_mut().for_each(|mut w| { w.visible = false; @@ -75,10 +77,16 @@ fn close_editor( fn toggle_editor( state: Res>, mut next_state: ResMut>, + keys: Res>, + mut catch: Local, ) { - info!("Toggling editor on/off"); - match state.get() { - EditorState::Open => next_state.set(EditorState::Closed), - EditorState::Closed => next_state.set(EditorState::Open), + if keys.pressed(KeyCode::F3) && !*catch { + *catch = true; + match state.get() { + EditorState::Open => next_state.set(EditorState::Closed), + EditorState::Closed => next_state.set(EditorState::Open), + } + } else { + *catch = false; } } \ No newline at end of file diff --git a/src/prelude.rs b/src/prelude.rs index 6a50409..ae55eab 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -10,9 +10,9 @@ pub(crate) use bevy::render::render_resource::{ Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages, }; pub(crate) use bevy::window::WindowRef; -pub(crate) use bevy::input::common_conditions::input_just_pressed; pub(crate) use bevy::window::{PrimaryWindow, WindowCloseRequested}; pub(crate) use bevy::window::ExitCondition; +pub(crate) use bevy::input::common_conditions::input_just_pressed; /// Bevy Plugins pub(crate) use bevy_mod_picking::prelude::*;