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:
Markus Ort 2023-11-16 22:31:25 +01:00 committed by Carter Anderson
parent 0dee514e61
commit 44fbc2f717

View file

@ -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,