Skip to content

Commit 840c320

Browse files
Change camera order ambiguity warning to warn_once! (#22649)
## Objective Fixes #22635 Camera order ambiguity warnings currently fire every frame, flooding the console. ## Solution - Change `warn!` to `warn_once!` in `sort_cameras` so the warning only fires once per ambiguity - Remove the log filter workaround from `ui_target_camera` example since the warning is no longer spammy ## Testing Ran the `ui_target_camera` example and triggered a camera order ambiguity by clicking to give two cameras the same order. Verified the warning appears exactly once in the logs despite running for many frames afterward. --------- Co-authored-by: Alice Cecile <[email protected]>
1 parent 9133047 commit 840c320

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

crates/bevy_render/src/camera.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ use bevy_ecs::{
4141
};
4242
use bevy_image::Image;
4343
use bevy_log::warn;
44+
use bevy_log::warn_once;
4445
use bevy_math::{uvec2, vec2, Mat4, URect, UVec2, UVec4, Vec2};
4546
use bevy_platform::collections::{HashMap, HashSet};
4647
use bevy_reflect::prelude::*;
@@ -652,7 +653,7 @@ pub fn sort_cameras(
652653
}
653654

654655
if !ambiguities.is_empty() {
655-
warn!(
656+
warn_once!(
656657
"Camera order ambiguities detected for active cameras with the following priorities: {:?}. \
657658
To fix this, ensure there is exactly one Camera entity spawned with a given order for a given RenderTarget. \
658659
Ambiguities should be resolved because either (1) multiple active cameras were spawned accidentally, which will \

examples/ui/ui_target_camera.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@ use bevy::color::palettes::css::BLUE;
44
use bevy::color::palettes::css::GREEN;
55
use bevy::color::palettes::css::RED;
66
use bevy::color::palettes::css::YELLOW;
7-
use bevy::log::LogPlugin;
8-
use bevy::log::DEFAULT_FILTER;
97
use bevy::prelude::*;
108

119
fn main() {
1210
App::new()
13-
.add_plugins(DefaultPlugins.set(LogPlugin {
14-
// Disable camera order ambiguity warnings
15-
filter: format!("{DEFAULT_FILTER},bevy_render::camera=off"),
16-
..Default::default()
17-
}))
11+
.add_plugins(DefaultPlugins)
1812
.add_systems(Startup, setup)
1913
.run();
2014
}

0 commit comments

Comments
 (0)