-
Is there a way to run a system only when a resource changes but still access the entities? Let's say I have a resource which specifies some property and a bunch of entities which need to update when that property changes. If I write something like this...
...I get called each frame. I would ideally want to get called only when Am I doing this wrong? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You would be using the 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. |
Beta Was this translation helpful? Give feedback.
You would be using the
Res::is_changed
methodSystems 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.