Closed BlitzBanana closed 1 year ago
The current implementation is only intended for use cases where you do not care which handle you are getting. Examples are random variants of things like tree or rock textures, or variants of sound effects.
In your case, it looks like you want the different skills to be separate handles on the asset collection.
I like the idea of a map from file names to handles. Thank you for the suggestion.
~Looking at the current asset server it does not seem to be possible to get the file path from a handle. If this would ever get possible we could load a directory as a map file path <-> handle, but not at the moment.~
Edit: this is just plain wrong. I overlooked the get_handle_path
method on the AssetServer.
For now, I'll close this.
Hello, I am interested too, is it still impossible? @NiklasEi
I think I overlooked a rather simple way of doing this. Thanks for the ping :slightly_smiling_face:
What do you think about the following: https://github.com/NiklasEi/bevy_asset_loader/blob/aa5fc0f3e94870e3a5c268616b4f3c7a916df9b2/bevy_asset_loader/examples/load_folder_as_map.rs#L20-L38
Using the new option now, I am not that convinced anymore that this is a valuable addition. The only difference from asset_server.get_handle("folder/image.png")
is that I stripped away the folder path (so collection.get("image.png").unwrap()
) and that the collection knows if the asset actually exists.
I'm a new user of this crate and Bevy in general, so not a good opinion on this. I would say that even if asset_server.get_handle()
is similar, this addition will reduce the boilerplate needed to load a collection from a folder in a way that we can access it using filename as key.
Hello,
I see that you are currently implementing a feature to load a folder into a
Vec<Handle<..>>
. I'm farily new to Bevy and Rust, so maybe I'm missing something here, but how do you plan this to be usable ? SinceHandle
s are justu64
identifiers, how do I know which handle I want to use/retreive ?Here is an example:
Could it be more practical to load folders into a
HashMap<String, Handle<..>>
, using the filename as a key ?Anyway, thanks for your work, this lib is great.