From 7382afc602fd8ce9f69af5efa6c7bab3f96d9697 Mon Sep 17 00:00:00 2001 From: xu_yanfeng Date: Sun, 19 Jan 2025 18:40:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwarning=E8=BF=87=E5=A4=9A?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cc-inspector/src/scripts/inject/inspector.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cc-inspector/src/scripts/inject/inspector.ts b/cc-inspector/src/scripts/inject/inspector.ts index f7c18b1..c730f60 100644 --- a/cc-inspector/src/scripts/inject/inspector.ts +++ b/cc-inspector/src/scripts/inject/inspector.ts @@ -313,7 +313,10 @@ export class Inspector extends InjectEvent { allKeys = allKeys.filter((key) => { try { - return typeof node[key] !== "function"; + this.warnSilent(true); + const type = typeof node[key]; + this.warnSilent(false); + return type !== "function"; } catch (e) { // console.warn(`属性${key}出现异常:\n`, e); return false; @@ -405,9 +408,19 @@ export class Inspector extends InjectEvent { } return null; } - + private warnSilent(v: boolean) { + if (typeof cc !== undefined && typeof cc.warn === "function") { + if (v) { + cc.warn = () => {}; + } else { + cc.warn = console.warn.bind(console); + } + } + } _genInfoData(node: any, key: string | number, path: Array): Info | null { + this.warnSilent(true); const propertyValue = node[key]; + this.warnSilent(false); const make = (info: Info | null) => { info.readonly = this._isReadonly(node, key); info.path = path;