Skip to content

Show warning when no camera is used #6978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions crates/bevy_render/src/camera/camera.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{
camera::CameraProjection,
mesh::Mesh,
prelude::Image,
render_asset::RenderAssets,
render_resource::TextureView,
Expand All @@ -16,6 +17,7 @@ use bevy_ecs::{
reflect::ReflectComponent,
system::{Commands, Query, Res},
};
use bevy_log::warn;
use bevy_math::{Mat4, Ray, UVec2, UVec4, Vec2, Vec3};
use bevy_reflect::prelude::*;
use bevy_reflect::FromReflect;
Expand Down Expand Up @@ -529,3 +531,14 @@ pub fn extract_cameras(
}
}
}

pub fn check_has_camera(
mesh_query: Extract<Query<&Handle<Mesh>>>,
camera_query: Extract<Query<&Camera>>,
) {
let has_meshes = !mesh_query.is_empty();
let has_cameras = !camera_query.is_empty();
if has_meshes && !has_cameras {
warn!("Trying to render meshes without a camera will not show anything!");
}
}
1 change: 1 addition & 0 deletions crates/bevy_render/src/camera/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl Plugin for CameraPlugin {
.add_plugin(CameraProjectionPlugin::<PerspectiveProjection>::default());

if let Ok(render_app) = app.get_sub_app_mut(RenderApp) {
render_app.add_system_to_stage(RenderStage::Extract, check_has_camera);
render_app.add_system_to_stage(RenderStage::Extract, extract_cameras);

let camera_driver_node = CameraDriverNode::new(&mut render_app.world);
Expand Down