Skip to content

Change detection when mixing queries and resources #5888

Answered by nicopap
nsabovic asked this question in Q&A
Discussion options

You must be logged in to vote

You would be using the Res::is_changed method

fn my_system(
    property: Res<Property>,
    mut query: Query<(&mut MyComponent)>,
) {
  if !property.is_changed() {
    return;
  }
  // Update your `MyComponent`s
}

Systems do not have a huge overhead, so it's not a big deal to let it run and check that your resource hasn't changed.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nsabovic
Comment options

Answer selected by alice-i-cecile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants