use bevy::{prelude::*, window::PresentMode}; use bevy_debug_overlay::{OverlayCamera, OverlayConfig, OverlayPlugin}; fn main() { App::new() .insert_resource(Msaa::Off) .add_plugins( DefaultPlugins .set(AssetPlugin { watch_for_changes: true, ..default() }) .set(WindowPlugin { primary_window: Some(Window { present_mode: PresentMode::AutoNoVsync, ..default() }), ..default() }), ) .insert_resource(OverlayConfig { advanced_mode: true, ..default() }) // Insert the plugin on the app .add_plugin(OverlayPlugin) .add_startup_system(setup_3d_scene) .add_system(update) .run(); } fn setup_3d_scene( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, ) { // camera commands.spawn(( Camera3dBundle { transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), ..default() }, // You need to add the component to your camera OverlayCamera::default(), )); // ground commands.spawn(PbrBundle { mesh: meshes.add(Mesh::from(shape::Plane { size: 5.0, subdivisions: 1, })), material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()), ..default() }); // cube commands.spawn(PbrBundle { mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })), material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..default() }); // light commands.spawn(PointLightBundle { point_light: PointLight { intensity: 1500.0, shadows_enabled: true, ..default() }, transform: Transform::from_xyz(4.0, 8.0, 4.0), ..default() }); } fn update(key: Res>, mut q: Query<&mut OverlayCamera>) { if key.just_pressed(KeyCode::F11) { for mut overlay in &mut q { overlay.enabled = !overlay.enabled; } } }