bevy
bevy copied to clipboard
Add `AssetServer::remove`
What problem does this solve or what need does it fill?
It is sometimes useful to manually unload assets, without having to track down and drop every existing handle. You can currently do this with Assets::remove
, but no equivalent method on AssetServer
exists.
What solution would you like?
Add AssetServer::remove
.
What alternative(s) have you considered?
Continue to use the workaround. This won't play nice with heterogenous asset collections, as you need to know the type of the asset.
Additional context
Oh wow, i completely missed that thinking it would be in AssetServer 😆 thank you!
Prompted by Carl on Discord.
I'll try my skills on this one if no one is working on it.
Yes please!
Is there still someone working on this issue?
@leonaellis Feel free to take a jab at it, I'm still trying things, but I might have rushed a bit trying to contribute. I'm actually curious to see how you would solve this issue.
Is anyone still working on this? If not, let me know and I'll try my hands on this.
Please feel free to give it a shot :) There's no PRs open so it's fair game.
@Olle-Lukowski go for it. I'm not on it anymore.
Ok, I took a look at the code, and I honestly can't figure it out. First time looking at the asset system's internals, and can't figure out where the live assets are stored. I still want to do this, but might need some guidance.
The underlying assets should be stored in the AssetServer
. Ping me on Discord if you need further help and I can poke at the code with you :)
This is much more complex than I anticipated. The AssetServer
seems to mostly be responsible for coordinating metadata and loading. It appears that the correct solution would be to add an additional InternalAssetEvent
variant to communicate to the Assets
storage to unload the underlying data, but I'm not exactly sure how this is done yet.