Skip to content

Commit

Permalink
Update GpuImage when Image changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Davier committed Dec 3, 2021
1 parent b6409e3 commit a6f1581
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pipelined/bevy_sprite2/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub struct ExtractedSprites {

#[derive(Default)]
pub struct SpriteAssetEvents {
images: Vec<AssetEvent<Image>>,
pub images: Vec<AssetEvent<Image>>,
}

pub fn extract_sprite_events(
Expand Down
14 changes: 12 additions & 2 deletions pipelined/bevy_ui2/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub use render_pass::*;
use std::ops::Range;

use bevy_app::prelude::*;
use bevy_asset::{Assets, Handle, HandleUntyped};
use bevy_asset::{AssetEvent, Assets, Handle, HandleUntyped};
use bevy_core::FloatOrd;
use bevy_ecs::prelude::*;
use bevy_math::{const_vec3, Mat4, Vec2, Vec3, Vec4Swizzles};
Expand All @@ -26,7 +26,7 @@ use bevy_render2::{
view::ViewUniforms,
RenderApp, RenderStage, RenderWorld,
};
use bevy_sprite2::TextureAtlas;
use bevy_sprite2::{SpriteAssetEvents, TextureAtlas};
use bevy_text2::{DefaultTextPipeline, Text};
use bevy_transform::components::GlobalTransform;
use bevy_utils::HashMap;
Expand Down Expand Up @@ -430,7 +430,17 @@ pub fn queue_uinodes(
gpu_images: Res<RenderAssets<Image>>,
mut ui_batches: Query<(Entity, &UiBatch)>,
mut views: Query<&mut RenderPhase<TransparentUi>>,
events: Res<SpriteAssetEvents>,
) {
// If an image has changed, the GpuImage has (probably) changed
for event in &events.images {
match event {
AssetEvent::Created { .. } => None,
AssetEvent::Modified { handle } => image_bind_groups.values.remove(handle),
AssetEvent::Removed { handle } => image_bind_groups.values.remove(handle),
};
}

if let Some(view_binding) = view_uniforms.uniforms.binding() {
ui_meta.view_bind_group = Some(render_device.create_bind_group(&BindGroupDescriptor {
entries: &[BindGroupEntry {
Expand Down

0 comments on commit a6f1581

Please sign in to comment.