bevyengine / bevyengine/bevy

Allow loading TextureAtlas with the asset server, configuring its layout using a .meta file

Open
#10,679 1 comment 0 reactions 0 assignees View on GitHub
A-Assets C-Feature C-Usability
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

To create a [`TextureAtlas`](https://docs.rs/bevy/0.12.0/bevy/prelude/struct.TextureAtlas.html), one must currently load the `Image` first and then create the texture atlas object and manually add it to the `Assets` resource.

This is less convenient than other asset loading, which you just need to load with the asset server. This also mean that you can't just let the asset server handle the unloading of the spritesheet - because the texture atlas which depends on it and holds a reference to it is not retrieved by the asset server, which means you have to either store an handle to it in a resource or risk creating it multiple times.

## What solution would you like?

Assets V2 introduced `.meta` files adjacent to the assets. These files can override the asset loader used to load the asset (which would otherwise depend on the file extension), and provide settings for it. We could use these settings to specify the rows and columns of the texture atlas.

Additionally, a (Bevy based) tool could be made to edit these meta files graphically.

## What alternative(s) have you considered?

I've found some projects that use an `.atlas` extension for a similar purpose:

* https://libgdx.com/wiki/tools/texture-packer#textureatlas
* http://esotericsoftware.com/spine-texture-packer#Texture-atlas-files

I could not, however, find actual examples or specification of that extension, and I suspect the syntax is different between them. Had there been a standard format for an adjacent file that defines a sprite sheet, with ecosystem support (e.g. - sprite editors able to write these files when exporting to PNG), it may have been preferable to use that format.

Of course, Bevy could also [start it's own such extension](https://xkcd.com/927/).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.