a bundle id, or the descriptor of the asset to free
with a bundle id, false when the bundle was not
loaded; with a descriptor, false when the asset was not in memory
synchronously, on an unknown bundle id, or a descriptor
whose type the loader keeps nothing for (a type registered with
loader.setParser without an unload: the game keeps those assets
itself)
Release a bundle, or free a single asset: a string is a bundle id, an object is an asset descriptor. So
loader.unload("map1")releases the bundle"map1", andloader.unload({ name: "map1", type: "tmx" })frees that one map, whichever bundles list it.With a bundle id (see loader.setBundle), the bundle lets go of each of its assets, and every one that nothing else still holds is freed: an asset another loaded bundle lists stays, and so does one loaded the old way (by
preload/loadwith a descriptor), which pins it. Freeing a map or a glTF scene this way also unregisters its level, solevel.loadof it throws "not found" until the bundle is loaded again. Unload the bundle of the level being left once the next level is in: unloading the bundle of the level being played leaves the world as it is, but with no current level, solevel.reload()has nothing to reload. Allowed while the bundle is still loading: its assets are then freed as they arrive.With an asset descriptor (only
nameandtypeare read), the asset is freed at once, whoever holds it: a bundle listing it reports loader.isLoadedfalseafterwards, and loading that bundle again fetches it again.Either way, freeing an image also frees the texture the renderer uploaded from it, a shader its GPU program, a font its place in
document.fonts. A Sprite Fusion map ("spritefusion") frees the spritesheet loaded with it, and an LDtk project the images loaded with it, unless something else still holds them. A tile map is freed under any of its type names ("tmx","tilemap","spritefusion"): they are one cache. A shader handed out by loader.getShader is not tracked once handed out, so an effect that outlives a level (a HUD's, a camera's) belongs in a bundle that outlives it too, or it is freed under whatever still uses it.