//! An example for debugging viewport coordinates use bevy::prelude::*; const PALETTE: [Color; 10] = [ Color::ORANGE, Color::BLUE, Color::WHITE, Color::BEIGE, Color::CYAN, Color::CRIMSON, Color::NAVY, Color::AZURE, Color::GREEN, Color::BLACK, ]; #[derive(Default, Debug, Hash, Eq, PartialEq, Clone, States)] enum Coords { #[default] Viewport, Pixel, } fn main() { App::new() .add_plugins(DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { resolution: [800., 600.].into(), title: "Viewport Coordinates Debug".to_string(), resizable: false, ..Default::default() }), ..Default::default() })) .add_state::() .add_systems(Startup, setup) .add_systems(OnEnter(Coords::Viewport), spawn_with_viewport_coords) .add_systems(OnEnter(Coords::Pixel), spawn_with_pixel_coords) .add_systems(OnExit(Coords::Viewport), despawn_nodes) .add_systems(OnExit(Coords::Pixel), despawn_nodes) .add_systems(Update, update) .run(); } fn despawn_nodes(mut commands: Commands, query: Query>) { for entity in query.iter() { commands.entity(entity).despawn(); } } fn update( mut timer: Local, time: Res