diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index 5c5aca45db..c852122e6a 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -759,7 +759,10 @@ pub fn queue_uinodes( draw_function, pipeline, entity: *entity, - sort_key: FloatOrd(extracted_uinode.stack_index as f32), + sort_key: ( + FloatOrd(extracted_uinode.stack_index as f32), + entity.index(), + ), // batch_range will be calculated in prepare_uinodes batch_range: 0..0, dynamic_offset: None, diff --git a/crates/bevy_ui/src/render/render_pass.rs b/crates/bevy_ui/src/render/render_pass.rs index f483c8cf0b..bde2898534 100644 --- a/crates/bevy_ui/src/render/render_pass.rs +++ b/crates/bevy_ui/src/render/render_pass.rs @@ -88,7 +88,7 @@ impl Node for UiPassNode { } pub struct TransparentUi { - pub sort_key: FloatOrd, + pub sort_key: (FloatOrd, u32), pub entity: Entity, pub pipeline: CachedRenderPipelineId, pub draw_function: DrawFunctionId, @@ -97,7 +97,7 @@ pub struct TransparentUi { } impl PhaseItem for TransparentUi { - type SortKey = FloatOrd; + type SortKey = (FloatOrd, u32); #[inline] fn entity(&self) -> Entity {