diff --git a/crates/bevy_sprite/src/texture_atlas.rs b/crates/bevy_sprite/src/texture_atlas.rs index 573c5ce57e..de1320767a 100644 --- a/crates/bevy_sprite/src/texture_atlas.rs +++ b/crates/bevy_sprite/src/texture_atlas.rs @@ -158,13 +158,15 @@ impl TextureAtlas { } /// Add a sprite to the list of textures in the `TextureAtlas` + /// returns an index to the texture which can be used with `TextureAtlasSprite` /// /// # Arguments /// /// * `rect` - The section of the atlas that contains the texture to be added, /// from the top-left corner of the texture to the bottom-right corner - pub fn add_texture(&mut self, rect: Rect) { + pub fn add_texture(&mut self, rect: Rect) -> u32 { self.textures.push(rect); + (self.textures.len() - 1) as u32 } /// How many textures are in the `TextureAtlas`