use bevy::prelude::*; use bevy_debug_overlay::{OverlayCamera, OverlayConfig, OverlayPlugin}; fn main() { App::new() .insert_resource(Msaa::Off) .add_plugins(DefaultPlugins) // If you need to configure it .insert_resource(OverlayConfig::default()) // Insert the plugin on the app .add_plugin(OverlayPlugin) .add_startup_system(setup_3d_scene) .add_system(update) .run(); } // This is simply the scene from the 3d_scene example of bevy 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>, mut config: ResMut, ) { if key.just_pressed(KeyCode::F11) { for mut overlay in &mut q { overlay.enabled = !overlay.enabled; } } if key.just_pressed(KeyCode::Z) { config.proportional_width = !config.proportional_width; } if key.just_pressed(KeyCode::X) { config.advanced_mode = !config.advanced_mode; } }