pub fn update_ui_size_and_scale_system(
    mut contexts: Query<UpdateUiSizeAndScaleQuery>,
    #[cfg(feature = "render")] images: Res<Assets<Image>>,
) {
    for mut context in contexts.iter_mut() {
        let mut render_target_size = None;
        if let Some(window) = context.window {
            render_target_size = Some(RenderTargetSize::new(
                window.physical_width() as f32,
                window.physical_height() as f32,
                window.scale_factor(),
            ));
        }
        #[cfg(feature = "render")]
        if let Some(EguiRenderToImage { handle, .. }) = context.render_to_image {
            if let Some(image) = images.get(handle) {
                let size = image.size_f32();
                render_target_size = Some(RenderTargetSize {
                    physical_width: size.x,
                    physical_height: size.y,
                    scale_factor: 1.0,
                })
            } else {
                log::warn!("Invalid EguiRenderToImage handle: {handle:?}");
            }
        }

        let Some(new_render_target_size) = render_target_size else {
            log::error!("bevy_egui context without window or render to texture!");
            continue;
        };
        let width = new_render_target_size.physical_width
            / new_render_target_size.scale_factor
            / context.egui_settings.scale_factor;
        let height = new_render_target_size.physical_height
            / new_render_target_size.scale_factor
            / context.egui_settings.scale_factor;

        if width < 1.0 || height < 1.0 {
            continue;
        }

        context.egui_input.screen_rect = Some(egui::Rect::from_min_max(
            egui::pos2(0.0, 0.0),
            egui::pos2(width, height),
        ));

        context.ctx.get_mut().set_pixels_per_point(
            new_render_target_size.scale_factor * context.egui_settings.scale_factor,
        );

        *context.render_target_size = new_render_target_size;
    }
}
Updates UI [`egui::RawInput::screen_rect`] and calls [`egui::Context::set_pixels_per_point`].
src/lib.rs