Bevy Heterogenous Texture Atlas Loader allows you to load heterogenous texture atlases according to a RON file manifest.
This works (as far as I can tell), but the implementation could be improved a lot. Any suggestions would be very welcome.
Suports Bevy 0.6
#
We have a sprite sheet example.png
for our game,
that has sprites with irregular sizes and positions.
manifest.ron
manifest file in your assets folder
(
"example.png",
Sprites ([
(
x: 18,
y: 19,
w: 46,
h: 48
),
(
x: 93,
y: 108,
w: 32,
h: 31
),
(
x: 176,
y: 34,
w: 20,
h: 34
),
])
)
Alternatively, you can give each sprite a unique name that can be used to look
up their TextureAtlas index.
(
"example.png",
NamedSprites ([
{
name: "yellow",
x: 18,
y: 19,
w: 46,
h: 48
},
{
name: "face",
x: 93,
y: 108,
w: 32,
h: 31
},
{
name: "patches",
x: 176,
y: 34,
w: 20,
h: 34
},
])
)
* You can call the manifest anything you like, not only manifest.ron
.
* The file path is relative to the root assets folder, not to the manifest file.
* The sprites are in a list not a map to preserve ordering. The sprite indices in the ouput ordered implicitly according to the order of the input list.
* Use name: ""
to skip naming a sprite in a NamedSprites
list
2. Add the BHTAL dependency to your Cargo.toml
bevy_heterogeneous_texture_atlas_loader = "0.1.2"
```rust use bevy::prelude::; use bevy_heterogeneous_texture_atlas_loader::;
fn setup(
mut commands: Commands,
assetserver: Res
fn onatlasloaded(
mut commands: Commands,
mut events: EventReader
fn main() { App::new() .addplugins(DefaultPlugins) .addplugin(HeterogeneousTextureAtlasLoaderPlugin) .addstartupsystem(setup) .addsystem(onatlas_loaded) .run(); } ``` 4. Result
#
I wish
"Manifest not found"?
You need to store a strong handle to the manifest in a resource or something, otherwise it will be dropped before the texture atlas is created.
Why are the names for everything so long?
Shorter than "Bevy Heterogenous Texture Atlas Ron Manifest Asynchronous Loader"