phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
37.22k stars 7.1k forks source link

Unload asset pack #6791

Closed tibimunteanu closed 4 months ago

tibimunteanu commented 7 months ago

The loader plugin can currently load all assets from an asset-pack via scene.load.pack(...), but it lacks the functionality for unloading an asset-pack.

Since the pack function must already have the code to read and iterate through assets in an asset-pack, maybe something like scele.load.unloadAssetPack(...) can be easy to implement, as it would just have to call destroy instead of load for each asset in the asset-pack.

Motivation: Building multi-scene games for mobile with lots of assets can be difficult to do without this, as it requires the developer to track every asset it loads and manually and individually unload it when needed. This is almost like managing an asset-pack manually and it kind of defeats the purpose of the builtin asset-pack. Pretty much all game engines support something along the lines of unload unused assets or unload asset bundle or unload scene (which also unloads the assets).

samme commented 7 months ago

Please try https://github.com/phaserjs/phaser/pull/6793

samme commented 4 months ago

Needs CHANGELOG entry.

zekeatchan commented 4 months ago

Needs CHANGELOG entry.

Thanks @samme. Have added the changelog entry.