From a7321f73fb203aa5ff4dd9a0ca7ba2a20dba1a57 Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 16 Mar 2024 19:07:28 +0100 Subject: [PATCH] start in full screen with mouse grabbed --- src/main.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index af04f75..4a7766c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,10 @@ use bevy::{ asset::LoadState, + window::{ + Window, + WindowMode, + PrimaryWindow, + }, core_pipeline::Skybox, prelude::*, render::{ @@ -35,8 +40,17 @@ const CUBEMAPS: &[(&str, CompressedImageFormats)] = &[ ), ]; -fn setup(mut commands: Commands, asset_server: Res) { +fn setup( + mut commands: Commands, + asset_server: Res, + mut windows: Query<&mut Window, With> +) { let skybox_handle = asset_server.load(CUBEMAPS[0].0); + for mut window in &mut windows { + window.cursor.grab_mode = CursorGrabMode::Locked; + window.cursor.visible = false; + window.mode = WindowMode::Fullscreen; + } // camera commands.spawn(( Camera3dBundle { @@ -233,6 +247,7 @@ fn run_camera_controller( controller.yaw = yaw; controller.pitch = pitch; controller.initialized = true; + *toggle_cursor_grab = true; info!("{}", *controller); } if !controller.enabled {