From 518c760737edfc2891095c8582741acf0c2965de Mon Sep 17 00:00:00 2001 From: zheng han Date: Thu, 10 Jun 2021 14:56:43 +0800 Subject: [PATCH] fire event in _addComponentAt (#8714) --- cocos/core/scene-graph/base-node-dev.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cocos/core/scene-graph/base-node-dev.ts b/cocos/core/scene-graph/base-node-dev.ts index 9efa214566f..fc7cd9d50ee 100644 --- a/cocos/core/scene-graph/base-node-dev.ts +++ b/cocos/core/scene-graph/base-node-dev.ts @@ -91,8 +91,11 @@ export function baseNodePolyfill (BaseNode) { comp.node = this; this._components.splice(index, 0, comp); - if ((EDITOR || TEST) && legacyCC.engine && (this._id in legacyCC.engine.attachedObjsForEditor)) { - legacyCC.engine.attachedObjsForEditor[comp._id] = comp; + if (EDITOR && EditorExtends.Node && EditorExtends.Component) { + const node = EditorExtends.Node.getNode(this._id); + if (node) { + EditorExtends.Component.add(comp._id, comp); + } } if (this._activeInHierarchy) { legacyCC.director._nodeActivator.activateComp(comp);