Skip to content

Commit 532195a

Browse files
authored
Try #2236:
2 parents 653c103 + 05f293b commit 532195a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

crates/bevy_ecs/src/system/commands.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,9 @@ where
338338
T: Bundle + 'static,
339339
{
340340
fn write(self: Box<Self>, world: &mut World) {
341-
world.entity_mut(self.entity).insert_bundle(self.bundle);
341+
if let Some(mut entity_mut) = world.get_entity_mut(self.entity) {
342+
entity_mut.insert_bundle(self.bundle);
343+
}
342344
}
343345
}
344346

@@ -353,7 +355,9 @@ where
353355
T: Component,
354356
{
355357
fn write(self: Box<Self>, world: &mut World) {
356-
world.entity_mut(self.entity).insert(self.component);
358+
if let Some(mut entity_mut) = world.get_entity_mut(self.entity) {
359+
entity_mut.insert(self.component);
360+
}
357361
}
358362
}
359363

0 commit comments

Comments
 (0)