mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Fix panic when using image in UiMaterial (#10591)
# Objective - Fix the panic on using Images in UiMaterials due to assets not being loaded. - Fixes #10513 ## Solution - add `let else` statement that `return`s or `continue`s instead of unwrapping, causing a panic.
This commit is contained in:
parent
0dee514e61
commit
44fbc2f717
1 changed files with 6 additions and 5 deletions
|
@ -298,10 +298,9 @@ impl<P: PhaseItem, M: UiMaterial, const I: usize> RenderCommand<P>
|
|||
materials: SystemParamItem<'w, '_, Self::Param>,
|
||||
pass: &mut TrackedRenderPass<'w>,
|
||||
) -> RenderCommandResult {
|
||||
let material = materials
|
||||
.into_inner()
|
||||
.get(&material_handle.material)
|
||||
.unwrap();
|
||||
let Some(material) = materials.into_inner().get(&material_handle.material) else {
|
||||
return RenderCommandResult::Failure;
|
||||
};
|
||||
pass.set_bind_group(I, &material.bind_group, &[]);
|
||||
RenderCommandResult::Success
|
||||
}
|
||||
|
@ -732,7 +731,9 @@ pub fn queue_ui_material_nodes<M: UiMaterial>(
|
|||
let draw_function = draw_functions.read().id::<DrawUiMaterial<M>>();
|
||||
|
||||
for (entity, extracted_uinode) in extracted_uinodes.uinodes.iter() {
|
||||
let material = render_materials.get(&extracted_uinode.material).unwrap();
|
||||
let Some(material) = render_materials.get(&extracted_uinode.material) else {
|
||||
continue;
|
||||
};
|
||||
for (view, mut transparent_phase) in &mut views {
|
||||
let pipeline = pipelines.specialize(
|
||||
&pipeline_cache,
|
||||
|
|
Loading…
Reference in a new issue