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; /** * 回调的数量 */