var textures = cc.textureCache.getAllTextures(); textures.sort(function (a, b) { return b.getPixelHeight() * b.getPixelWidth() - a.getPixelHeight() * a.getPixelWidth(); }); for (var key in textures) { var selfTexture = textures[key]; var url = selfTexture.url; var num = (selfTexture.getPixelWidth() * selfTexture.getPixelHeight() * (url.indexOf('.jpg') > 0 ? 3 : 4) / 1024 / 1024).toFixed(2); console.log(url + ".........." + num + "M"); }
更新在2.0的话。cc.textureCache.getAllTextures()弃用,
这里给出个新思路
let Loader: any = cc.loader; this.dumpLabel.string = `当前资源总数:${Object.keys(Loader._cache).length}`;