mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 22:20:20 +00:00
Better error message when index does not exist in texture atlas (#8396)
# Objective - Fixes https://github.com/bevyengine/bevy/issues/8210 ## Changelog - Improve error message when `TextureAtlasSprite::index` does not exist in texture atlas
This commit is contained in:
parent
b03b7b557e
commit
defc653528
1 changed files with 12 additions and 1 deletions
|
@ -396,7 +396,18 @@ pub fn extract_sprites(
|
|||
continue;
|
||||
}
|
||||
if let Some(texture_atlas) = texture_atlases.get(texture_atlas_handle) {
|
||||
let rect = Some(texture_atlas.textures[atlas_sprite.index]);
|
||||
let rect = Some(
|
||||
*texture_atlas
|
||||
.textures
|
||||
.get(atlas_sprite.index)
|
||||
.unwrap_or_else(|| {
|
||||
panic!(
|
||||
"Sprite index {:?} does not exist for texture atlas handle {:?}.",
|
||||
atlas_sprite.index,
|
||||
texture_atlas_handle.id(),
|
||||
)
|
||||
}),
|
||||
);
|
||||
extracted_sprites.sprites.push(ExtractedSprite {
|
||||
entity,
|
||||
color: atlas_sprite.color,
|
||||
|
|
Loading…
Reference in a new issue