From 6cbf89ec6c339efdafcd59a3df95fc6faac82150 Mon Sep 17 00:00:00 2001 From: fengyuzhe Date: Wed, 3 Jun 2026 14:54:17 +0800 Subject: [PATCH 1/2] Revert "Fix the issue where cli class-registered does not receive messages. (#150)" This reverts commit 99f6db401c4e67c59f45eba0a49891f7ce1f282b. --- cocos/core/data/class.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/cocos/core/data/class.ts b/cocos/core/data/class.ts index 275a5f057f..e2660c5d36 100644 --- a/cocos/core/data/class.ts +++ b/cocos/core/data/class.ts @@ -195,22 +195,15 @@ function define (className, baseClass, options): any { renderName = 'render_stage'; } // 增加了 hidden: 开头标识,使它最终不会显示在 Editor inspector 的添加组件列表里 - if (globalThis.EditorExtends) { - globalThis.EditorExtends.Component.addMenu(cls, `hidden:${renderName}/${className}`, -1); - } + + window.EditorExtends && window.EditorExtends.Component.addMenu(cls, `hidden:${renderName}/${className}`, -1); } // Note: `options.ctor` should be the same as `cls` except if // cc-class is defined by `cc.Class({/* ... */})`. // In such case, `options.ctor` may be `undefined`. // So we can not use `options.ctor`. Instead, we should use `cls` which is the "real" registered cc-class. - // Emit via globalThis.EditorExtends to ensure the event reaches - // both the engine-internal and the scene-bundle event systems. - if (globalThis.EditorExtends) { - globalThis.EditorExtends.emit('class-registered', cls, frame, className); - } else { - EditorExtends.emit('class-registered', cls, frame, className); - } + EditorExtends.emit('class-registered', cls, frame, className); } if (frame) { From b80934cae58f91a189e11ad589f4231fb0ce1dc6 Mon Sep 17 00:00:00 2001 From: fengyuzhe Date: Wed, 3 Jun 2026 15:01:16 +0800 Subject: [PATCH 2/2] refine --- cocos/core/data/class.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos/core/data/class.ts b/cocos/core/data/class.ts index e2660c5d36..46051661e6 100644 --- a/cocos/core/data/class.ts +++ b/cocos/core/data/class.ts @@ -195,8 +195,9 @@ function define (className, baseClass, options): any { renderName = 'render_stage'; } // 增加了 hidden: 开头标识,使它最终不会显示在 Editor inspector 的添加组件列表里 - - window.EditorExtends && window.EditorExtends.Component.addMenu(cls, `hidden:${renderName}/${className}`, -1); + if (window.EditorExtends) { + window.EditorExtends.Component.addMenu(cls, `hidden:${renderName}/${className}`, -1); + } } // Note: `options.ctor` should be the same as `cls` except if