From ff10be89e363069a7ad34664b2b52f45ec6d4690 Mon Sep 17 00:00:00 2001 From: xu_yanfeng Date: Tue, 29 Apr 2025 11:27:28 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E5=A4=8Dcreator2.x=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=EF=BC=8C=E7=82=B9=E5=87=BBscene=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E6=8A=A5=E9=94=99=EF=BC=9A"getComponent"=20is=20not=20defined?= =?UTF-8?q?=20in=20the=20Scene,=20it=20is=20only=20defined=20in=20normal?= =?UTF-8?q?=20nodes.=20-=20=E4=BF=AE=E5=A4=8Dcc.warn=20is=20not=20a=20func?= =?UTF-8?q?tion=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scripts/inject/inspector.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/scripts/inject/inspector.ts b/src/scripts/inject/inspector.ts index 4f5b070..5531bbe 100644 --- a/src/scripts/inject/inspector.ts +++ b/src/scripts/inject/inspector.ts @@ -592,16 +592,27 @@ export class Inspector extends InjectEvent { } return null; } + /**保存原来的warn函数*/ + private originWarn = null; private warnSilent(v: boolean) { if (typeof cc !== undefined && typeof cc.warn === "function") { if (v) { + this.originWarn = cc.warn; cc.warn = () => {}; } else { - cc.warn = console.warn.bind(console); + // document.cookie.match(/(^|;)\s*debug\s*=\s*(\d+)/) + // 0 是none, 2.x值来自 cookie + // 2.x: cc.debug._resetDebugSetting(0) + // 3.x: cc.debug._resetDebugSetting(0) + cc.warn = this.originWarn; + // eval("console.warn.bind(console)"); // 这种方式可能有性能问题 } } } private isDisabledX(node: any, item: Info) { + if (cc.Scene && node instanceof cc.Scene) { + return true; + } const widget = node.getComponent(cc.Widget); if (widget && widget.enabled) { if (widget.isAlignLeft) { @@ -617,6 +628,9 @@ export class Inspector extends InjectEvent { return false; } private isDisabledY(node: any, item: Info) { + if (cc.Scene && node instanceof cc.Scene) { + return true; + } const widget = node.getComponent(cc.Widget); if (widget && widget.enabled) { if (widget.isAlignTop) {