macro_rules! screen_print {
    (col: $color:expr, $text:expr $(, $fmt_args:expr)*) => { ... };
    (sec: $timeout:expr, col: $color:expr, $text:expr $(, $fmt_args:expr)*) => { ... };
    (sec: $timeout:expr, $text:expr $(, $fmt_args:expr)*) => { ... };
    ($text:expr $(, $fmt_args:expr)*) => { ... };
    (@impl sec: $timeout:expr, col: $color:expr, $text:expr $(, $fmt_args:expr)*) => { ... };
}
Expand description

Display text on top left corner of the screen.

Usage

Call screen_print! like you would call any format!-style macros from the standard lib.

You can also customize color and timeout, by adding prefix arguments:

  • sec: <timeout>: specify in seconds for how long the text shows up (default is 7 seconds)
  • col: <color>: specify the color of the text. Default is fallback_color provided in OverlayPlugin, which itself defaults to yellow.

If both prefixes are used, you must specify sec before col.

use bevy_debug_text_overlay::{screen_print, OverlayPlugin};
use bevy::prelude::Color;

let x = (13, 3.4, vec![1,2,3,4,5,6,7,8]);
screen_print!("multiline: {x:#?}");
screen_print!(sec: 6.0, "first and second fields: {}, {}", x.0, x.1);
screen_print!(col: Color::BLUE, "single line: {x:?}");
screen_print!(sec: 10.0, col: Color::BLUE, "last field: {:?}", x.2);