[SOLVED] How to load texture before lightmaped info initialize?

Hello forum!
I was optmizing the VRAM used on Apple devices. Here is the problem.
I unloaded the textureassets used by the render in the first scene when they get the ‘destroy’ call. And load them when initialize after change back to the first scene. Scripts are shown below.

var SceneAssetsManager = pc.createScript('sceneAssetsManager');


SceneAssetsManager.attributes.add("asetsManaged", { type: "asset", array: true });

SceneAssetsManager.prototype.initialize = function () {

    for (var i = 0; i < this.asetsManaged.length; i++) {
        if (this.asetsManaged[i] != undefined) {
            this.app.assets.load(this.asetsManaged[i]);
        }
    }

    this.entity.on('destroy',
        function () {

            for (var i = 0; i < this.asetsManaged.length; i++) {

                if (this.asetsManaged[i] != undefined) {
                    this.asetsManaged[i].unload();
                }
            }

        }.bind(this)

    );

};

The problem is, when I change back to the first scene. I see all the textures correctly. But I can not bake the lightmap any more. I even try write thing like bake the lightmap when press the keyboard to see if it is because it’s not fully initialize. But it takes no effect either.
After, I tried load them before the scene is loaded. It works, but no help with the VRAM optmization becasues these assets should not take up the VRAM in the scene.
I guess it’s something with lightmaped info initialize. Any suggestions?

By the way. The game runs at 264MB total VRAM. But still crashes on the device at random time around 2 miniutes later. Is there anyway to monitor other memory use besides VRAM in the game?

Turns out it is because of the batch group thing. Batch is not going well with lightmap bake. I knew that but I still going in the wrong way.:rofl: