Skip to content

Commit b8c58de

Browse files
SludgePhDmockersf
authored andcommitted
Avoid panicking with non-UI nodes (#12213)
# Objective - Fixes #10826 - Fixes #9615 ## Solution - Early-out when components are missing.
1 parent 8234978 commit b8c58de

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

crates/bevy_ui/src/layout/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,9 @@ pub fn ui_layout_system(
411411
mut absolute_location: Vec2,
412412
) {
413413
if let Ok((mut node, mut transform)) = node_transform_query.get_mut(entity) {
414-
let layout = ui_surface.get_layout(entity).unwrap();
414+
let Ok(layout) = ui_surface.get_layout(entity) else {
415+
return;
416+
};
415417
let layout_size =
416418
inverse_target_scale_factor * Vec2::new(layout.size.width, layout.size.height);
417419
let layout_location =

crates/bevy_ui/src/update.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ fn update_children_target_camera(
155155

156156
for &child in children {
157157
// Skip if the child has already been updated or update is not needed
158-
if updated_entities.contains(&child) || camera_to_set == node_query.get(child).unwrap() {
158+
if updated_entities.contains(&child)
159+
|| camera_to_set == node_query.get(child).ok().flatten()
160+
{
159161
continue;
160162
}
161163

0 commit comments

Comments
 (0)