Preloading assets using script

Hey everyone,

I’m currently working on preloading assets with a loading bar in my MainScene before transitioning to the gameScene. Initially, I used a method where I assigned a tag to each asset/mesh and then loaded them using:

var assets = this.app.assets.findByTag(this.sceneName);

This approach worked well, but it became quite time-consuming on larger projects due to the need to tag each asset individually.

I’m now exploring alternative methods to preload all assets without having to assign tags to each one individually. Does anyone have suggestions or insights on how to accomplish this efficiently?

Thanks in advance for any help or advice you can provide!.

Tried with below one

    this.app.assets.loadFromUrlAndFilename("assets/DummySceneAssets/", (err, assets) => {
        if (err) {
            console.error("Error loading assets:");
            return;
        } else {
            console.log("assets")
        }
    });

But seems to be getting error.
Can anyone guide to me to the same. Thank you !!

Hi @gouthamamin,

I had the same issue with tags. Here is an example of parsing the scenes at app startup to discover which assets each scenes requires, and using this to load and unload assets when changing scenes.