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
							
								
									c7f5cec8be
								
							
						
					
					
						commit
						efc7dc0859
					
				| @ -298,10 +298,9 @@ impl<P: PhaseItem, M: UiMaterial, const I: usize> RenderCommand<P> | |||||||
|         materials: SystemParamItem<'w, '_, Self::Param>, |         materials: SystemParamItem<'w, '_, Self::Param>, | ||||||
|         pass: &mut TrackedRenderPass<'w>, |         pass: &mut TrackedRenderPass<'w>, | ||||||
|     ) -> RenderCommandResult { |     ) -> RenderCommandResult { | ||||||
|         let material = materials |         let Some(material) = materials.into_inner().get(&material_handle.material) else { | ||||||
|             .into_inner() |             return RenderCommandResult::Failure; | ||||||
|             .get(&material_handle.material) |         }; | ||||||
|             .unwrap(); |  | ||||||
|         pass.set_bind_group(I, &material.bind_group, &[]); |         pass.set_bind_group(I, &material.bind_group, &[]); | ||||||
|         RenderCommandResult::Success |         RenderCommandResult::Success | ||||||
|     } |     } | ||||||
| @ -732,7 +731,9 @@ pub fn queue_ui_material_nodes<M: UiMaterial>( | |||||||
|     let draw_function = draw_functions.read().id::<DrawUiMaterial<M>>(); |     let draw_function = draw_functions.read().id::<DrawUiMaterial<M>>(); | ||||||
| 
 | 
 | ||||||
|     for (entity, extracted_uinode) in extracted_uinodes.uinodes.iter() { |     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 { |         for (view, mut transparent_phase) in &mut views { | ||||||
|             let pipeline = pipelines.specialize( |             let pipeline = pipelines.specialize( | ||||||
|                 &pipeline_cache, |                 &pipeline_cache, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Markus Ort
						Markus Ort