File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed
crates/bevy_ui/src/layout Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ use bevy_math::{UVec2, Vec2};
1212use bevy_render:: camera:: { Camera , NormalizedRenderTarget } ;
1313use bevy_sprite:: BorderRect ;
1414use bevy_transform:: components:: Transform ;
15+ use bevy_utils:: once;
1516use bevy_window:: { PrimaryWindow , Window , WindowScaleFactorChanged } ;
1617use thiserror:: Error ;
1718use tracing:: warn;
@@ -164,10 +165,10 @@ pub fn ui_layout_system(
164165 match camera_with_default ( target_camera) {
165166 Some ( camera_entity) => {
166167 let Ok ( ( _, camera) ) = cameras. get ( camera_entity) else {
167- warn ! (
168+ once ! ( warn!(
168169 "UiTargetCamera (of root UI node {entity}) is pointing to a camera {} which doesn't exist" ,
169170 camera_entity
170- ) ;
171+ ) ) ;
171172 return ;
172173 } ;
173174 let layout_info = camera_layout_info
@@ -177,13 +178,13 @@ pub fn ui_layout_system(
177178 }
178179 None => {
179180 if cameras. is_empty ( ) {
180- warn ! ( "No camera found to render UI to. To fix this, add at least one camera to the scene." ) ;
181+ once ! ( warn!( "No camera found to render UI to. To fix this, add at least one camera to the scene." ) ) ;
181182 } else {
182- warn ! (
183+ once ! ( warn!(
183184 "Multiple cameras found, causing UI target ambiguity. \
184185 To fix this, add an explicit `UiTargetCamera` component to the root UI node {}",
185186 entity
186- ) ;
187+ ) ) ;
187188 }
188189 }
189190 }
Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ struct Args {
5050 /// set the root node to display none, removing all nodes from the layout.
5151 #[ argh( switch) ]
5252 display_none : bool ,
53+
54+ /// spawn the layout without a camera
55+ #[ argh( switch) ]
56+ no_camera : bool ,
5357}
5458
5559/// This example shows what happens when there is a lot of buttons on screen.
@@ -82,9 +86,11 @@ fn main() {
8286 } )
8387 . add_systems ( Update , ( button_system, set_text_colors_changed) ) ;
8488
85- app. add_systems ( Startup , |mut commands : Commands | {
86- commands. spawn ( Camera2d ) ;
87- } ) ;
89+ if !args. no_camera {
90+ app. add_systems ( Startup , |mut commands : Commands | {
91+ commands. spawn ( Camera2d ) ;
92+ } ) ;
93+ }
8894
8995 if args. grid {
9096 app. add_systems ( Startup , setup_grid) ;
You can’t perform that action at this time.
0 commit comments