From 42f74e587dbc338f16ab5b52a87aa90e1be267c2 Mon Sep 17 00:00:00 2001 From: xu_yanfeng Date: Tue, 29 Apr 2025 14:03:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=A6=82=E6=9E=9C=E6=8C=82?= =?UTF-8?q?=E7=9A=84=E6=9C=89=E7=94=A8=E6=88=B7=E8=84=9A=E6=9C=AC=EF=BC=8C?= =?UTF-8?q?=E4=BC=9A=E6=98=BE=E7=A4=BATS=E5=9B=BE=E6=A0=87=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E4=B8=94=E9=BC=A0=E6=A0=87=E9=95=BF=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=94=BE=E4=B8=8A=E5=8E=BB=E5=90=8E=EF=BC=8C=E4=BC=9A=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E8=84=9A=E6=9C=AC=E7=9A=84=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cc-plugin.config.ts | 2 +- src/scripts/inject/inspector.ts | 19 +++++++++++++++++++ src/views/devtools/data.ts | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cc-plugin.config.ts b/cc-plugin.config.ts index 2cfdb45..afa7711 100644 --- a/cc-plugin.config.ts +++ b/cc-plugin.config.ts @@ -9,7 +9,7 @@ function i18n(key: string) { const manifest: CocosPluginManifest = { name: pkgName, - version: "2.1.14", + version: "2.1.16", description: "Debug games made with CocosCreator and display node trees and node properties", store: "https://store.cocos.com/app/detail/2002", author: "xu_yanfeng", diff --git a/src/scripts/inject/inspector.ts b/src/scripts/inject/inspector.ts index 5531bbe..aab3d4a 100644 --- a/src/scripts/inject/inspector.ts +++ b/src/scripts/inject/inspector.ts @@ -348,6 +348,20 @@ export class Inspector extends InjectEvent { return ""; } } + private getUserScripts(node: any): string[] { + const ret: string[] = []; + const comps = node._components; + if (comps) { + for (let i = 0; i < comps.length; i++) { + const comp = comps[i]; + const compName = this.getCompName(comp); + if (!compName.startsWith("cc")) { + ret.push(compName); + } + } + } + return ret; + } // 收集节点信息 getNodeChildren(node: any, data: TreeData) { data.id = node.uuid; @@ -361,6 +375,11 @@ export class Inspector extends InjectEvent { // 场景不允许获取active,引擎会报错 } else { data.active = !!node.active && !!node.activeInHierarchy; + const scripts = this.getUserScripts(node); + if (scripts.length) { + data.subfixIcon = "icon_ts_text"; + data.subfixIconTip = scripts.join("\n"); + } } this.inspectorGameMemoryStorage[node.uuid] = node; let nodeChildren = node.children; diff --git a/src/views/devtools/data.ts b/src/views/devtools/data.ts index 0729d06..8aab4a1 100644 --- a/src/views/devtools/data.ts +++ b/src/views/devtools/data.ts @@ -530,6 +530,8 @@ export class TreeData implements ITreeData { id: string = ""; icon: string = ""; color: string = ""; + subfixIcon?: string; + subfixIconTip?: string; /** * 回调的数量 */