accessing entity mutably in a query when using World #13720
Replies: 1 comment
-
ended up using SystemState to essentially run a system with access to the outer world resource let mut system: bevy::ecs::system::SystemState<(
Commands,
Query<(Entity, &Handle<StandardMaterial>)>,
)> = bevy::ecs::system::SystemState::new(&mut scene.world);
let (mut scene_commands, handles) = system.get_mut(&mut scene.world);
for (ent, handle) in &handles {
if let Some(mat) = standard.remove(handle) {
let mut entity = scene_commands.entity(ent);
entity.remove::<Handle<StandardMaterial>>();
entity.insert(overlay.add(bevy::pbr::ExtendedMaterial {
base: mat,
extension: material::Overlay {},
}));
}
}
system.apply(&mut scene.world); |
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.
-
i'm trying to edit a scene by swapping materials before spawning it into the world but since the world is mutably borrowed for the query it can't be mutably borrowed again to sort out components on the entity
this is solved in normal systems by deferring using commands but don't think this is an option here
i can't run a system within the world since it requires resources from the outer world where the material assets resources are
any ideas on how to solve this?
Beta Was this translation helpful? Give feedback.
All reactions