Closed thebluefish closed 2 years ago
You can either manually configure the dynamic TextureAtlas
, or define it in a .assets
file.
Currently, in your first code example, you are trying to define the .assets
file as a file asset on the key tileset
, which is supposed to be the TextureAtlas
. For this kind of manual registration of the key, you would need to do this instead:
asset_keys.register_asset(
"tileset",
DynamicAsset::TextureAtlas {
path: "textures/tilesets/standard_128.png".to_owned(),
tile_size_x: 96.,
tile_size_y: 128.,
columns: 10,
rows: 4,
padding_x: None,
padding_y: None
},
);
This would be the point in code where you can change the file path based on which one you want to be loaded.
On current main, you can now also register .assets
files in a system. You could for example run the following system before the loading state MyStates::AssetLoading
fn setup_loading_state(mut dynamic_asset_collections: ResMut<DynamicAssetCollections<MyStates>>) {
dynamic_asset_collections
.files
.get_mut(&MyStates::AssetLoading)
.unwrap()
.push("textures/tilesets/standard_128.assets".to_owned());
}
This would then replace .with_asset_collection_file("textures/tilesets/tileset.assets")
and allow you to decide which .assets
file to load at run-time.
I will close this for now, because I think this was more of a misunderstanding about how dynamic assets should work.
If you still run into issues or have suggestions on how I could make the plugin better, don't hesitate to reopen or start a new issue.
I would like to configure which texture atlas to use at runtime. Each is currently defined in their own
.assets
resource like:However I cannot seem to load these as a normal dynamic asset. I'm attempting to do the following:
However it works fine when I define it as part of a dynamic collection:
The dynamic loading stops throwing a warning when I use the same format as a collection file, but fails to properly load the TextureAtlas.