OK so the window works

main
Elijah C. Voigt 1 year ago
parent 43a3bdab3e
commit 37ce68b162

@ -58,6 +58,7 @@ fn init_editor(
fn open_editor( fn open_editor(
mut ws: Query<&mut Window, With<Editor>>, mut ws: Query<&mut Window, With<Editor>>,
state: Res<State<EditorState>>,
) { ) {
ws.iter_mut().for_each(|mut w| { ws.iter_mut().for_each(|mut w| {
w.visible = true; w.visible = true;
@ -66,6 +67,7 @@ fn open_editor(
fn close_editor( fn close_editor(
mut ws: Query<&mut Window, With<Editor>>, mut ws: Query<&mut Window, With<Editor>>,
state: Res<State<EditorState>>,
) { ) {
ws.iter_mut().for_each(|mut w| { ws.iter_mut().for_each(|mut w| {
w.visible = false; w.visible = false;
@ -75,10 +77,16 @@ fn close_editor(
fn toggle_editor( fn toggle_editor(
state: Res<State<EditorState>>, state: Res<State<EditorState>>,
mut next_state: ResMut<NextState<EditorState>>, mut next_state: ResMut<NextState<EditorState>>,
keys: Res<ButtonInput<KeyCode>>,
mut catch: Local<bool>,
) { ) {
info!("Toggling editor on/off"); if keys.pressed(KeyCode::F3) && !*catch {
*catch = true;
match state.get() { match state.get() {
EditorState::Open => next_state.set(EditorState::Closed), EditorState::Open => next_state.set(EditorState::Closed),
EditorState::Closed => next_state.set(EditorState::Open), EditorState::Closed => next_state.set(EditorState::Open),
} }
} else {
*catch = false;
}
} }

@ -10,9 +10,9 @@ pub(crate) use bevy::render::render_resource::{
Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages, Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages,
}; };
pub(crate) use bevy::window::WindowRef; 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::{PrimaryWindow, WindowCloseRequested};
pub(crate) use bevy::window::ExitCondition; pub(crate) use bevy::window::ExitCondition;
pub(crate) use bevy::input::common_conditions::input_just_pressed;
/// Bevy Plugins /// Bevy Plugins
pub(crate) use bevy_mod_picking::prelude::*; pub(crate) use bevy_mod_picking::prelude::*;

Loading…
Cancel
Save