Commit 468bfa95 authored by limingzhe's avatar limingzhe

fix: 清内存

parent 4b33e0f1
cc.Class({
extends: cc.Component,
onDestroy() {
console.log('喵喵喵: destroyer onDestroy');
middleLayer.clearDragonDisplayAssetList();
}
});
{
"ver": "1.0.8",
"uuid": "ddd21bda-bd5e-4e01-938a-e933c777725e",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -181,6 +181,19 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -181,6 +181,19 @@ export abstract class middleLayerBase extends cc.Component {
this.addToLoadBundleBuffer(sceneName, version, bondleUrl, callback) this.addToLoadBundleBuffer(sceneName, version, bondleUrl, callback)
return; return;
} }
this.assetList = [];
this.textureList = [];
this.atlasList = [];
this.nodeList = [];
console.log('汪汪汪: getDragonDisplayAssetList');
this.getDragonDisplayAssetList(cc.find('Canvas'));
console.log('喵喵喵1: ' + this.nodeList.length);
console.log('喵喵喵2: ' + this.atlasList.length);
console.log('喵喵喵3: ' + this.assetList.length);
console.log('喵喵喵4: ' + this.textureList.length);
this.loadBundleLock = true; // 加锁 this.loadBundleLock = true; // 加锁
this.currentBundleInfo = { sceneName, version, bondleUrl }; this.currentBundleInfo = { sceneName, version, bondleUrl };
console.log("[middleLayer_for_NJ_lite]-[loadBundle] currentBundleInfo=", JSON.stringify(this.currentBundleInfo)) console.log("[middleLayer_for_NJ_lite]-[loadBundle] currentBundleInfo=", JSON.stringify(this.currentBundleInfo))
...@@ -214,6 +227,12 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -214,6 +227,12 @@ export abstract class middleLayerBase extends cc.Component {
canvas.getComponent(cc.Widget).updateAlignment(); canvas.getComponent(cc.Widget).updateAlignment();
middleLayer.scale = canvas.width / middleLayer.width; middleLayer.scale = canvas.width / middleLayer.width;
const destroyer = cc.instantiate(cc.find('middleLayer/Destroyer'));
destroyer.parent = cc.find('Canvas');
destroyer.active = true;
callback && callback(); callback && callback();
}); });
...@@ -381,4 +400,67 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -381,4 +400,67 @@ export abstract class middleLayerBase extends cc.Component {
.removeSelf() .removeSelf()
.start(); .start();
} }
clearDragonDisplayAssetList() {
console.log('喵喵喵: clearDragonDisplayAssetList');
console.log('喵喵喵: ' + this.nodeList.length);
console.log('喵喵喵: ' + this.atlasList.length);
console.log('喵喵喵: ' + this.assetList.length);
console.log('喵喵喵: ' + this.textureList.length);
[...this.atlasList, ...this.assetList].forEach(asset => {
asset.decRef();
cc.assetManager.releaseAsset(asset);
asset.destroy();
});
this.nodeList.forEach(node => {
node.active = false;
node.removeFromParent();
});
this.textureList.forEach(texture => {
texture.decRef();
});
}
nodeList = null;
atlasList = null;
assetList = null;
textureList = null;
getDragonDisplayAssetList(node) {
const dragonDisplay = node.getComponent(dragonBones.ArmatureDisplay);
if (dragonDisplay) {
const atlas = dragonDisplay.dragonAtlasAsset;
const asset = dragonDisplay.dragonAsset;
if (atlas.texture) {
if (atlas.texture.nativeUrl.includes('h5template')) {
node.children.forEach(child => {
this.getDragonDisplayAssetList(child);
});
return;
}
this.nodeList.push(node);
this.atlasList.push(atlas);
this.assetList.push(asset);
this.textureList.push(atlas.texture);
console.log('汪汪汪: atlas.texture.nativeUrl = ' + atlas.texture.nativeUrl);
}
}
node.children.forEach(child => {
this.getDragonDisplayAssetList(child);
});
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment