Closed meanbeanmachine closed 1 year ago
The expectation for unloading is that you take care of this yourself. Because, as you already mentioned, different people/games will want different collections to stay and others to be unloaded.
It should be enough to add on_exit
systems to a state and use commands.remove_resource::<MyAssetCollection>()
to unload that collection. Bevy will then take care of unloading the assets, as long as you do not save handles to the assets anywhere outside of the asset collection.
Okie dokie, thanks.
Do you plan to implement asset unloading? From my tests, this doesn't appear to take place:
This would not be good for applications with large amounts of assets.
Additionally, in my Component despawn function that runs on state exit, I tried AssetServer::free_unused_assets() but that doesn't work either. My knowledge is limited, but I'm guessing it has something to do with the Assets being loaded as Strong handles? Either way, it would be nice if AssetCollections would unload assets if the new state doesn't use them.
I suppose the problem implementing this feature would be that some people would prefer assets to stay loaded, and others not. Maybe an unload option could be set for a collection, individual assets, or both; i.e. tag a collection to be automatically unloaded, except where otherwise specified on the individual asset... and of course vice versa.