How to query and access resources in exclusive world query #11587
Unanswered
feelingsonice
asked this question in
Q&A
Replies: 1 comment
-
You would use the It allows accessing system parameters similarly to a system, but using a let mut system_state: SystemState<(
Query<(Entity, &mut Transform)>,
Query<&mut Visibility>,
)> = SystemState::new(world);
let (mut transforms, mut visibs) = system_state.get_mut(world);
for (entity, mut tran) in &mut transforms {
let Ok(mut vis) = visibs.get_mut(entity) else {
continue;
};
// ...
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Please correct me if I'm wrong, but it seems like the only way to query for anything when using exclusive world queries is through the use of a mutable borrow, something like this:
The method signature of
QueryState::iter()
is indeedpub fn iter<'w, 's>(&'s mut self, world: &'w World)
.So..., this means that you cannot access any other readonly data while this is happening. For me, I need to access a
Resource
while iterating the query, but I can't...So how does one go about doing something like this considering it's a common use case?
Beta Was this translation helpful? Give feedback.
All reactions