From c463dd76db10de1f368b29e9b3cc677331f00397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Rom=C3=A1n=20N=C3=BA=C3=B1ez?= Date: Sun, 20 Sep 2026 18:22:45 +0200 Subject: [PATCH] Remove UI multi cam setup --- src/menus/character_select/mod.rs | 2 +- src/menus/cursor.rs | 2 +- src/menus/mod.rs | 28 ++++++++++++++-------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/menus/character_select/mod.rs b/src/menus/character_select/mod.rs index d20b911..cd5dd75 100644 --- a/src/menus/character_select/mod.rs +++ b/src/menus/character_select/mod.rs @@ -241,7 +241,7 @@ pub fn copy_cursor_transform_to_token( character_boxes: Query<(&CharacterBox, &ComputedNode, &UiGlobalTransform)>, match_config: Res, cursors: Query<&UiGlobalTransform, With>, - cam: Single<&Camera, With>, + cam: Single<&Camera>, ui_scale: Res, ) -> Result { let camera = cam.into_inner(); diff --git a/src/menus/cursor.rs b/src/menus/cursor.rs index 5c783a8..40a4845 100644 --- a/src/menus/cursor.rs +++ b/src/menus/cursor.rs @@ -181,7 +181,7 @@ pub fn cursor_input( } pub fn update_cursor_transform( - camera: Single<&Camera, With>, + camera: Single<&Camera>, query: Query<(&mut Node, &PointerLocation), With>, ui_scale: Res, ) { diff --git a/src/menus/mod.rs b/src/menus/mod.rs index 054520b..ff7d0f1 100644 --- a/src/menus/mod.rs +++ b/src/menus/mod.rs @@ -25,6 +25,8 @@ pub mod style; #[derive(Component, Clone, Default)] pub struct MenuMarker {} +#[derive(Component, Clone, Default)] +pub struct MenuCameraMarker {} pub struct MenuPlugin; @@ -38,6 +40,7 @@ pub fn wrap_menu(menu: impl Scene) -> impl Scene { bsn! { #MenuRoot MenuMarker + Transform Node { width: percent(100), height: percent(100), @@ -46,6 +49,11 @@ pub fn wrap_menu(menu: impl Scene) -> impl Scene { flex_direction: FlexDirection::Column, } Children [ + ( + #MenuCamera + Camera + Camera2d + ), ( #MenuContainer Node { @@ -65,15 +73,18 @@ pub fn wrap_menu(menu: impl Scene) -> impl Scene { pub fn despawn_menu( existing_menu: Option>>, + existing_menu_camera: Option>>, mut commands: Commands, ) { if let Some(entity) = existing_menu { commands .entity(entity.into_inner()) - .remove::() - .remove::() .despawn(); } + + if let Some(menu_cam) = existing_menu_camera { + commands.entity(*menu_cam).despawn(); + } } pub fn spawn_menu( @@ -84,8 +95,6 @@ pub fn spawn_menu( if let Some(entity) = existing_menu { commands .entity(entity.into_inner()) - .remove::() - .remove::() .despawn(); } commands.queue_spawn_scene(wrap_menu(menu)); @@ -113,16 +122,7 @@ impl Plugin for MenuPlugin { fn build(&self, app: &mut App) { app.add_systems( OnEnter(AppState::MainMenu), - (build_menu::, |mut commands: Commands| { - commands.spawn((Camera2d, IsDefaultUiCamera)); - commands.spawn(( - Camera2d, - Camera { - order: 1, - ..default() - }, - )); - }), + build_menu::, ) .add_message::() .init_resource::() -- 2.54.0