mirror of
				https://github.com/potato47/ccc-devtools.git
				synced 2025-10-31 19:35:51 +00:00 
			
		
		
		
	feat(3.0.0):支持creator3.0
This commit is contained in:
		
							
								
								
									
										23
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								README.md
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | |||||||
| # ccc-devtools v3.0.1 | # ccc-devtools v3.0.0 | ||||||
| Cocos Creator 网页调试工具,运行时查看、修改节点树,实时更新节点属性,可视化缓存资源。 | Cocos Creator 网页调试工具,运行时查看、修改节点树,实时更新节点属性,可视化缓存资源。 | ||||||
|  |  | ||||||
| ## 功能 | ## 功能 | ||||||
| @@ -25,27 +25,12 @@ Cocos Creator 网页调试工具,运行时查看、修改节点树,实时更 | |||||||
|  |  | ||||||
| ## 全局使用 | ## 全局使用 | ||||||
|  |  | ||||||
| 1. 点击 Creator 右上角进入编辑器 resources 目录,再依次进入`static/preview-templates`目录 | Cocos Creator 3.0暂不支持全局使用 | ||||||
|  |  | ||||||
|     |  | ||||||
|  |  | ||||||
| 2. 将本项目clone到上面的目录下,**如果使用下载压缩包的方式记得把后缀名-master去掉** |  | ||||||
|  |  | ||||||
|     |  | ||||||
|  |  | ||||||
| 3. 打开 `index.jade`,找到 `body` 将中间部分替换为 `include ./ccc-devtools/index.html`,**注意用tab键对齐** |  | ||||||
|  |  | ||||||
|     |  | ||||||
|  |  | ||||||
| ## 项目使用 | ## 项目使用 | ||||||
|  |  | ||||||
| Cocos Creator 从 v2.2 开始新增了自定义网页预览功能。 | - `cd PROJECT_PATH && git clone -b v3.0.0 https://github.com/potato47/ccc-devtools.git preview-template` | ||||||
|  | - 或者手动将本项目对应分支下载到项目目录后,将名字改为 `preview-template` | ||||||
| 1. 重复上面的操作步骤,将修改后的 `preview-templates` 目录拷贝到项目根目录 |  | ||||||
|  |  | ||||||
| 2. 将 `ccc-devtools/index.html` 里所有引用的资源路径 `app/editor/static/preview-templates/ccc-devtools/...` 替换为 `ccc-devtools/...` |  | ||||||
|  |  | ||||||
| 3. 重启 Cocos Creator |  | ||||||
|  |  | ||||||
| ## 自定义 | ## 自定义 | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										23
									
								
								index.ejs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								index.ejs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | |||||||
|  | <html> | ||||||
|  |     <head> | ||||||
|  |         <link rel="icon" href="./favicon.ico" /> | ||||||
|  |         <meta charset="utf-8" /> | ||||||
|  |         <title><%=title%></title> | ||||||
|  |         <meta | ||||||
|  |             name="viewport" | ||||||
|  |             content="width=device-width,user-scalable=no,initial-scale=1, minimum-scale=1,maximum-scale=1" | ||||||
|  |         /> | ||||||
|  |         <meta name="apple-mobile-web-app-capable" content="yes" /> | ||||||
|  |         <meta name="full-screen" content="yes" /> | ||||||
|  |         <meta name="screen-orientation" content="portrait" /> | ||||||
|  |         <meta name="x5-fullscreen" content="true" /> | ||||||
|  |         <meta name="360-fullscreen" content="true" /> | ||||||
|  |         <meta name="renderer" content="webkit" /> | ||||||
|  |         <meta name="force-rendering" content="webkit" /> | ||||||
|  |         <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | ||||||
|  |         <link rel="stylesheet" type="text/css" href="./index.css" /> | ||||||
|  |     </head> | ||||||
|  |     <body> | ||||||
|  |         <%- include("./ccc-devtools/index.html") %> | ||||||
|  |     </body> | ||||||
|  | </html> | ||||||
| @@ -217,6 +217,7 @@ | |||||||
|             <v-divider></v-divider> |             <v-divider></v-divider> | ||||||
|             <v-card-text> |             <v-card-text> | ||||||
|                 <v-data-table :headers="cacheHeaders" :items="cacheData" :search="cacheSearchText" :sort-by="['size']" |                 <v-data-table :headers="cacheHeaders" :items="cacheData" :search="cacheSearchText" :sort-by="['size']" | ||||||
|  |                     click:row="openGithub" | ||||||
|                     :sort-desc="[true]" :footer-props="{ |                     :sort-desc="[true]" :footer-props="{ | ||||||
|                         showFirstLastPage: true, |                         showFirstLastPage: true, | ||||||
|                         firstIcon: 'mdi-chevron-double-left', |                         firstIcon: 'mdi-chevron-double-left', | ||||||
|   | |||||||
| @@ -131,50 +131,29 @@ const initConsoleUtil = function () { | |||||||
|         return target; |         return target; | ||||||
|     } |     } | ||||||
|     cc.cache = function () { |     cc.cache = function () { | ||||||
|         let rawCacheData = cc.loader._pipes[0].pipeline._cache; |         let rawCacheData = cc.loader._cache; | ||||||
|         let cacheData = []; |         let cacheData = []; | ||||||
|         let totalTextureSize = 0; |         let totalTextureSize = 0; | ||||||
|         for (let k in rawCacheData) { |         for (let k in rawCacheData) { | ||||||
|             let item = rawCacheData[k]; |             let item = rawCacheData[k]; | ||||||
|             if (item.type !== 'js' && item.type !== 'json') { |  | ||||||
|                 let itemName = '_'; |  | ||||||
|             let preview = ''; |             let preview = ''; | ||||||
|                 let content = (item.content && item.content.__classname__) ? item.content.__classname__ : item.type; |             let type = item.__classname__; | ||||||
|             let formatSize = -1; |             let formatSize = -1; | ||||||
|                 if (item.type === 'png' || item.type === 'jpg') { |             if (type === 'cc.Texture2D') { | ||||||
|                     let texture = rawCacheData[k.replace('.' + item.type, '.json')]; |                 let image = item.mipmaps[0] | ||||||
|                     if (texture && texture._owner) { |                 preview = image.url; | ||||||
|                         itemName = texture._owner._name; |                 let textureSize = image.width * image.height * ((image._native === '.jpg' ? 3 : 4) / 1024 / 1024); | ||||||
|                         preview = texture.content.url; |  | ||||||
|                     } |  | ||||||
|                 } else { |  | ||||||
|                     if (item.content.name && item.content.name.length > 0) { |  | ||||||
|                         itemName = item.content.name; |  | ||||||
|                     } else if (item._owner) { |  | ||||||
|                         itemName = (item._owner && item._owner.name) || '_'; |  | ||||||
|                     } |  | ||||||
|                     if (content === 'cc.Texture2D') { |  | ||||||
|                         let texture = item.content; |  | ||||||
|                         preview = texture._mipmaps[0].url; |  | ||||||
|                         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') { |  | ||||||
|                         preview = item.content._texture._mipmaps[0].url; |  | ||||||
|                     } |  | ||||||
|             } |             } | ||||||
|             cacheData.push({ |             cacheData.push({ | ||||||
|                     queueId: item.queueId, |                 type: type, | ||||||
|                     type: item.type, |  | ||||||
|                     name: itemName, |  | ||||||
|                 preview: preview, |                 preview: preview, | ||||||
|                     id: item.id, |                 id: item._uuid, | ||||||
|                     content: content, |  | ||||||
|                 size: formatSize |                 size: formatSize | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|         } |  | ||||||
|         let cacheTitle = `缓存 [文件总数:${cacheData.length}][纹理缓存:${totalTextureSize.toFixed(2) + 'M'}]`; |         let cacheTitle = `缓存 [文件总数:${cacheData.length}][纹理缓存:${totalTextureSize.toFixed(2) + 'M'}]`; | ||||||
|         return [cacheData, cacheTitle]; |         return [cacheData, cacheTitle]; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -10,10 +10,8 @@ const app = new Vue({ | |||||||
|         cacheTitle: '', |         cacheTitle: '', | ||||||
|         cacheHeaders: [ |         cacheHeaders: [ | ||||||
|             { text: 'Type', value: 'type' }, |             { text: 'Type', value: 'type' }, | ||||||
|             { 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: [], | ||||||
| @@ -153,7 +151,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; | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -1,6 +0,0 @@ | |||||||
| { |  | ||||||
|     "name": "ccc-devtools", |  | ||||||
|     "version": "3.0.1", |  | ||||||
|     "author": "Next", |  | ||||||
|     "repo": "https://github.com/potato47/ccc-devtools.git" |  | ||||||
| } |  | ||||||
		Reference in New Issue
	
	Block a user