Skip to content

Conversation

@shishanyue
Copy link

Objective

About #19727

Solution

  • Remove load_folder API,LoadedFolder and so on
  • add LoadedBatch ,LoadBatchRequest
  • use the crate glob

Testing

-rewrite the example texture_atlas.rs

//before
// Load multiple, individual sprites from a folder
commands.insert_resource(RpgSpriteFolder(asset_server.load_folder("textures/rpg")));

//now
commands.insert_resource(RpgSpriteFolder(asset_server.load_batch(
    LoadBatchRequest::new(vec!["textures/rpg/**/*", "textures/rpg/chars/**/*"]),
)));

Problem

But there have a problem.I can't get the base path.I need in load_batch_internal to glob the all file.

format!("assets/{}", request_path)

How can I obtain the unprocessed_path and processed_path under load_batch? I have used the crate glob. If I want to use it, I must prepend 'assets' to the path. However, it is evident that we can change it, and even add additional paths like in extra_file. Therefore, I need to retrieve the corresponding full path through AssetPath in load_batch. But I cannot find any method to achieve this.

@greeble-dev greeble-dev added C-Feature A new feature, making something new possible A-Assets Load files from disk to use for things like images, models, and sounds M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Help The author needs help finishing this PR. labels Jun 21, 2025
Comment on lines +11 to +18
pub fn new<T>(requests: Vec<T>) -> Self
where
T: Into<AssetPath<'static>>,
{
Self {
requests: requests.into_iter().map(Into::into).collect(),
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but nicer (allows more than just vec![foo, bar]):

Suggested change
pub fn new<T>(requests: Vec<T>) -> Self
where
T: Into<AssetPath<'static>>,
{
Self {
requests: requests.into_iter().map(Into::into).collect(),
}
}
pub fn new<T>(requests: impl IntoIterator<Item = T>) -> Self
where
T: Into<AssetPath<'static>>,
{
Self {
requests: requests.into_iter().map(Into::into).collect(),
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Assets Load files from disk to use for things like images, models, and sounds C-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Needs-Help The author needs help finishing this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants