Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kyrosle opened this issue Sep 4, 2022 · 6 comments
Closed

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

kyrosle opened this issue Sep 4, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@kyrosle
Copy link

kyrosle commented Sep 4, 2022

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 nicopap added the bug Something isn't working label Sep 4, 2022
@nicopap
Copy link
Owner

nicopap commented Sep 4, 2022

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
Copy link
Author

kyrosle commented Sep 5, 2022

all right, thanks for you reply

@thefakeplace
Copy link

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
Copy link
Owner

nicopap commented Mar 15, 2023

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

@nicopap
Copy link
Owner

nicopap commented Mar 15, 2023

Fixed by 0e19579

@nicopap nicopap closed this as completed Mar 15, 2023
@thefakeplace
Copy link

Wow, awesome! Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants