节点如果挂的有用户脚本,会显示TS图标,并且鼠标长时间放上去后,会显示脚本的名字

This commit is contained in:
xu_yanfeng 2025-04-29 14:03:11 +08:00
parent ff10be89e3
commit 42f74e587d
3 changed files with 22 additions and 1 deletions

View File

@ -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",

View File

@ -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;

View File

@ -530,6 +530,8 @@ export class TreeData implements ITreeData {
id: string = "";
icon: string = "";
color: string = "";
subfixIcon?: string;
subfixIconTip?: string;
/**
*
*/