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

Res<Windows> is always changed... only run code when window is resized for example? #4632

Closed
SUPERCILEX opened this issue Apr 29, 2022 · 3 comments
Labels
A-Windowing Platform-agnostic interface layer to run your app in S-User-Error This issue was caused by a mistake in the user's approach

Comments

@SUPERCILEX
Copy link
Contributor

Bevy version

0.7

What you did

fn window_scaling(windows: Res<Windows>) {
    if !windows.is_changed() {
        return;
    }

    // ...
}

What you expected to happen

is_changed returns false sometimes.

What actually happened

Instead, it appears to always be true. Is this expected?

#4530 seems like it could fix things.

@SUPERCILEX SUPERCILEX added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Apr 29, 2022
@DJMcNab
Copy link
Member

DJMcNab commented Apr 29, 2022

To react to window events, you should listen to the relevant events. For example,

fn react_to_resize(mut resized_events: EventReader<WindowResized>){
     for size_change in resized_events.iter() {
         // React to change
     }
}

I don't think Windows being changed every frame was explicitely known, but I didn't have any indication it wouldn't have been.

@DJMcNab DJMcNab added A-Windowing Platform-agnostic interface layer to run your app in S-User-Error This issue was caused by a mistake in the user's approach and removed C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Apr 29, 2022
@SUPERCILEX
Copy link
Contributor Author

Oooooh, TIL! Thanks. BTW, is there a more performant way to get the last event than just .iter().last()?

@SUPERCILEX
Copy link
Contributor Author

Actually I need to filter by the primary window anyway, so nvm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in S-User-Error This issue was caused by a mistake in the user's approach
Projects
None yet
Development

No branches or pull requests

2 participants