bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Add `AssetServer::remove`

Open alice-i-cecile opened this issue 11 months ago • 12 comments

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.

alice-i-cecile avatar Mar 19 '24 02:03 alice-i-cecile

I'll try my skills on this one if no one is working on it.

SSebigo avatar Mar 28 '24 09:03 SSebigo

Yes please!

alice-i-cecile avatar Mar 28 '24 13:03 alice-i-cecile

Is there still someone working on this issue?

leonaellis avatar Apr 20 '24 07:04 leonaellis

@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.

SSebigo avatar Apr 20 '24 08:04 SSebigo

Is anyone still working on this? If not, let me know and I'll try my hands on this.

Olle-Lukowski avatar May 27 '24 11:05 Olle-Lukowski

Please feel free to give it a shot :) There's no PRs open so it's fair game.

alice-i-cecile avatar May 27 '24 13:05 alice-i-cecile

@Olle-Lukowski go for it. I'm not on it anymore.

SSebigo avatar May 27 '24 13:05 SSebigo

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.

Olle-Lukowski avatar May 27 '24 14:05 Olle-Lukowski

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 :)

alice-i-cecile avatar May 27 '24 14:05 alice-i-cecile

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.

alice-i-cecile avatar May 27 '24 14:05 alice-i-cecile