Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid panicking with non-UI nodes #12213

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/bevy_ui/src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_ui/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down