支持2.4版本

This commit is contained in:
nextfu 2020-10-30 11:40:51 +08:00
parent 6bf3876262
commit adfe9cf217
4 changed files with 12 additions and 15 deletions

View File

@ -1,4 +1,4 @@
# ccc-devtools v3.0.1 # ccc-devtools
Cocos Creator 网页调试工具,运行时查看、修改节点树,实时更新节点属性,可视化缓存资源。 Cocos Creator 网页调试工具,运行时查看、修改节点树,实时更新节点属性,可视化缓存资源。
## 功能 ## 功能

View File

@ -117,7 +117,7 @@ const initConsoleUtil = function () {
return target; return target;
} }
cc.cache = function () { cc.cache = function () {
let rawCacheData = cc.loader._cache; let rawCacheData = cc.assetManager.assets._map;
let cacheData = []; let cacheData = [];
let totalTextureSize = 0; let totalTextureSize = 0;
for (let k in rawCacheData) { for (let k in rawCacheData) {
@ -125,7 +125,7 @@ const initConsoleUtil = function () {
if (item.type !== 'js' && item.type !== 'json') { if (item.type !== 'js' && item.type !== 'json') {
let itemName = '_'; let itemName = '_';
let preview = ''; let preview = '';
let content = (item.content && item.content.__classname__) ? item.content.__classname__ : item.type; let content = item.__classname__;
let formatSize = -1; let formatSize = -1;
if (item.type === 'png' || item.type === 'jpg') { if (item.type === 'png' || item.type === 'jpg') {
let texture = rawCacheData[k.replace('.' + item.type, '.json')]; let texture = rawCacheData[k.replace('.' + item.type, '.json')];
@ -134,29 +134,27 @@ const initConsoleUtil = function () {
preview = texture.content.url; preview = texture.content.url;
} }
} else { } else {
if (item.content.name && item.content.name.length > 0) { if (item.name) {
itemName = item.content.name; itemName = item.name;
} else if (item._owner) { } else if (item._owner) {
itemName = (item._owner && item._owner.name) || '_'; itemName = (item._owner && item._owner.name) || '_';
} }
if (content === 'cc.Texture2D') { if (content === 'cc.Texture2D') {
let texture = item.content; preview = item.nativeUrl;
preview = texture.url; let textureSize = item.width * item.height * ((item._native === '.jpg' ? 3 : 4) / 1024 / 1024);
let textureSize = texture.width * texture.height * ((texture._native === '.jpg' ? 3 : 4) / 1024 / 1024);
totalTextureSize += textureSize; totalTextureSize += textureSize;
// sizeStr = textureSize.toFixed(3) + 'M'; // sizeStr = textureSize.toFixed(3) + 'M';
formatSize = Math.round(textureSize * 1000) / 1000; formatSize = Math.round(textureSize * 1000) / 1000;
} else if (content === 'cc.SpriteFrame') { } else if (content === 'cc.SpriteFrame') {
preview = item.content._texture.url; preview = item._texture.nativeUrl;
} }
} }
cacheData.push({ cacheData.push({
queueId: item.queueId, queueId: item.queueId,
type: item.type, type: content,
name: itemName, name: itemName,
preview: preview, preview: preview,
id: item.id, id: item._uuid,
content: content,
size: formatSize size: formatSize
}); });
} }

View File

@ -13,7 +13,6 @@ const app = new Vue({
{ text: 'Name', value: 'name' }, { text: 'Name', value: 'name' },
{ text: 'Preivew', value: 'preview' }, { text: 'Preivew', value: 'preview' },
{ text: 'ID', value: 'id' }, { text: 'ID', value: 'id' },
{ text: 'Content', value: 'content' },
{ text: 'Size', value: 'size' }, { text: 'Size', value: 'size' },
], ],
cacheRawData: [], cacheRawData: [],
@ -143,7 +142,7 @@ const app = new Vue({
}, },
updateCacheData() { updateCacheData() {
if (this.$data.cacheOnlyTexture) { if (this.$data.cacheOnlyTexture) {
this.$data.cacheData = this.$data.cacheRawData.filter(item => item.content === 'cc.Texture2D'); this.$data.cacheData = this.$data.cacheRawData.filter(item => item.type === 'cc.Texture2D');
} else { } else {
this.$data.cacheData = this.$data.cacheRawData; this.$data.cacheData = this.$data.cacheRawData;
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "ccc-devtools", "name": "ccc-devtools",
"version": "3.0.1", "version": "2d-v2.4",
"author": "Next", "author": "Next",
"repo": "https://github.com/potato47/ccc-devtools.git" "repo": "https://github.com/potato47/ccc-devtools.git"
} }