diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index 31f123ff6d3f5..df3ac93372bb6 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -411,7 +411,9 @@ pub fn ui_layout_system( mut absolute_location: Vec2, ) { if let Ok((mut node, mut transform)) = node_transform_query.get_mut(entity) { - let layout = ui_surface.get_layout(entity).unwrap(); + let Ok(layout) = ui_surface.get_layout(entity) else { + return; + }; let layout_size = inverse_target_scale_factor * Vec2::new(layout.size.width, layout.size.height); let layout_location = diff --git a/crates/bevy_ui/src/update.rs b/crates/bevy_ui/src/update.rs index 44faa3d42bae1..d3750996d9398 100644 --- a/crates/bevy_ui/src/update.rs +++ b/crates/bevy_ui/src/update.rs @@ -155,7 +155,9 @@ fn update_children_target_camera( for &child in children { // Skip if the child has already been updated or update is not needed - if updated_entities.contains(&child) || camera_to_set == node_query.get(child).unwrap() { + if updated_entities.contains(&child) + || camera_to_set == node_query.get(child).ok().flatten() + { continue; }