nicopap / bevy-debug-text-overlay

A convenient on-screen message print macro for bevy.
Apache License 2.0
39 stars 5 forks source link

when using screen-print in query.iterator may loss message #2

Closed kyrosle closed 1 year ago

kyrosle commented 2 years ago

hello , i feel confused when i am using the screen_paint! in my query in the system function, my query type is such as query: Query<&GlobalTrasnform>, then the using postion is screen_print!("{:?}", trans.translation())

nicopap commented 2 years ago

Yeah, each screen_print! call has a "slot." And calling it repetitively will overwrite the previous value, even within the same frame. The workaround is to first collect your iterator and then screen_print! the resulting value.

// WORKAROUND:
// do not do this
for foo in &iterator {
  screen_print!("{foo:?}");
}
// do this instead
let foos: Vec<_> = iterator.iter().collect();
screen_print!("{foos:#?}");

This is not a trivial fix because, I need to be able to "identify" the line to print, so that calling it once per frame doesn't spawn an additional line per frame, but rather just replaces the previous line.

kyrosle commented 2 years ago

all right, thanks for you reply

thefakeplace commented 1 year ago

Would you consider changing this? I'm using this for my game and I would like to log messages when clients connect.

Naturally, if two clients connect in quick succession, I don't see what I expect. Maybe an optional parameter?

nicopap commented 1 year ago

I've missed this functionality myself a bunch. This is a good reason to add it.

nicopap commented 1 year ago

Fixed by 0e19579

thefakeplace commented 1 year ago

Wow, awesome! Thank you so much!