Skip to content

Commit 3f8a762

Browse files
committed
Working example
1 parent 09d342e commit 3f8a762

File tree

1 file changed

+10
-17
lines changed
  • crates/bevy_ui/src/render

1 file changed

+10
-17
lines changed

crates/bevy_ui/src/render/mod.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -194,28 +194,18 @@ pub fn extract_uinodes(
194194
continue;
195195
}
196196

197-
let (image, atlas_size, rect) = match image {
197+
let (image, atlas_size, rect_min) = match image {
198198
UiImage::Image(handle) => {
199199
let handle = handle.clone_weak();
200-
(
201-
handle,
202-
None,
203-
bevy_sprite::Rect {
204-
min: Vec2::ZERO,
205-
max: uinode.size,
206-
},
207-
)
200+
(handle, None, Vec2::ZERO)
208201
}
209202
UiImage::TextureAtlas { handle, index } => {
210203
let handle = handle.clone_weak();
211204
if let Some(atlas) = texture_atlases.get(&handle) {
212-
(
213-
atlas.texture.clone_weak(),
214-
Some(atlas.size),
215-
atlas.textures.get(*index).copied().unwrap_or_else(|| {
216-
panic!("TextureAtlas {:?} as no texture at index {}", atlas, index)
217-
}),
218-
)
205+
let rect = atlas.textures.get(*index).copied().unwrap_or_else(|| {
206+
panic!("TextureAtlas {:?} as no texture at index {}", atlas, index)
207+
});
208+
(atlas.texture.clone_weak(), Some(atlas.size), rect.min)
219209
} else {
220210
// Skip loading images
221211
continue;
@@ -229,7 +219,10 @@ pub fn extract_uinodes(
229219
extracted_uinodes.uinodes.push(ExtractedUiNode {
230220
transform: transform.compute_matrix(),
231221
color: color.0,
232-
rect,
222+
rect: bevy_sprite::Rect {
223+
min: rect_min,
224+
max: rect_min + uinode.size,
225+
},
233226
image,
234227
atlas_size,
235228
clip: clip.map(|clip| clip.clip),

0 commit comments

Comments
 (0)