The purpose of the "library" attribute

I know the optional “library” attribute for the tags.

Now, what is the purpose of this attribute? Is it simply a way to better organize the assets when calling them form code or does it disclose a series of advantages I am not aware of?

We used to have a special DefaultAssetLibrary class that handled pretty much all assets, then supported the addition of custom asset library types (such as from the SWF library). We have continued to improve this process, so that now the project.xml can define multiple asset libraries, as few or as many as you want. This adds a convenience where now you can load or unload groups of files in your application.

This has been demonstrated for defining a “preloader” asset library, but could be used for anything, such as for different levels.

<assets path="Assets/levels/level1" rename="level1" library="level1" />
<library name="level1" preload="false" />
Assets.loadLibrary ("level1").onComplete (function (_) {
    Assets.list ("level1:");
});

...

Assets.unloadLibrary ("level1");
1 Like