From f53af2846cc5694c7e96980630f59fa6fe1d2e25 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Tue, 1 Oct 2024 23:02:02 +0100 Subject: [PATCH] Update the UI texture slice pipeline to work with the retained render world changes (#15578) # Objective Update the UI's texture slice extraction to work with the changes from the retained render world PR (#15320). --- crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs b/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs index c8b9cfb9b2977..9811376a32fa4 100644 --- a/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs @@ -18,6 +18,7 @@ use bevy_render::{ renderer::{RenderDevice, RenderQueue}, texture::{BevyDefault, GpuImage, Image, TRANSPARENT_IMAGE_HANDLE}, view::*, + world_sync::{RenderEntity, TemporaryRenderEntity}, Extract, ExtractSchedule, Render, RenderSet, }; use bevy_sprite::{ @@ -258,6 +259,7 @@ pub fn extract_ui_texture_slices( Option<&TextureAtlas>, )>, >, + mapping: Extract>, ) { for (uinode, transform, view_visibility, clip, camera, image, image_scale_mode, atlas) in &slicers_query @@ -267,6 +269,10 @@ pub fn extract_ui_texture_slices( continue; }; + let Ok(&camera_entity) = mapping.get(camera_entity) else { + continue; + }; + // Skip invisible images if !view_visibility.get() || image.color.is_fully_transparent() @@ -291,7 +297,7 @@ pub fn extract_ui_texture_slices( }; extracted_ui_slicers.slices.insert( - commands.spawn_empty().id(), + commands.spawn(TemporaryRenderEntity).id(), ExtractedUiTextureSlice { stack_index: uinode.stack_index, transform: transform.compute_matrix(), @@ -302,7 +308,7 @@ pub fn extract_ui_texture_slices( }, clip: clip.map(|clip| clip.clip), image: image.texture.id(), - camera_entity, + camera_entity: camera_entity.id(), image_scale_mode: image_scale_mode.clone(), atlas_rect, flip_x: image.flip_x,