Add TextureAtlas convenience methods (#19023)
# Objective - Add a few useful methods to `TextureAtlas`. ## Solution - Added `TextureAtlas::with_index()`. - Added `TextureAtlas::with_layout()`. ## Testing - CI checks.
This commit is contained in:
parent
2affecdb07
commit
8c34cbbb27
@ -222,6 +222,18 @@ impl TextureAtlas {
|
|||||||
let atlas = texture_atlases.get(&self.layout)?;
|
let atlas = texture_atlases.get(&self.layout)?;
|
||||||
atlas.textures.get(self.index).copied()
|
atlas.textures.get(self.index).copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns this [`TextureAtlas`] with the specified index.
|
||||||
|
pub fn with_index(mut self, index: usize) -> Self {
|
||||||
|
self.index = index;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns this [`TextureAtlas`] with the specified [`TextureAtlasLayout`] handle.
|
||||||
|
pub fn with_layout(mut self, layout: Handle<TextureAtlasLayout>) -> Self {
|
||||||
|
self.layout = layout;
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Handle<TextureAtlasLayout>> for TextureAtlas {
|
impl From<Handle<TextureAtlasLayout>> for TextureAtlas {
|
||||||
|
Loading…
Reference in New Issue
Block a user