//! A simple example for debugging viewport coordinates //! //! This example creates two uinode trees, one using viewport coordinates and one using pixel coordinates, //! and then switches between them once per second using the `Display` style property. //! If there are no problems both layouts should be identical, except for the color of the margin changing which is used to signal that the displayed uinode tree has changed //! (red for viewport, yellow for pixel). use bevy::prelude::*; const PALETTE: [LegacyColor; 10] = [ LegacyColor::RED, LegacyColor::YELLOW, LegacyColor::WHITE, LegacyColor::BEIGE, LegacyColor::CYAN, LegacyColor::CRIMSON, LegacyColor::NAVY, LegacyColor::AZURE, LegacyColor::GREEN, LegacyColor::BLACK, ]; #[derive(Component, Default, PartialEq)] enum Coords { #[default] Viewport, Pixel, } fn main() { App::new() .insert_resource(UiScale(2.0)) .add_plugins(DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { title: "Viewport Coordinates Debug".to_string(), // This example relies on these specific viewport dimensions, so let's explicitly // define them. resolution: [1280., 720.].into(), resizable: false, ..Default::default() }), ..Default::default() })) .add_systems(Startup, setup) .add_systems(Update, update) .run(); } fn update( mut timer: Local, mut visible_tree: Local, time: Res