From 92e99f303812a8ac16f67a3cee9fc1f7cddf8682 Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Tue, 29 May 2018 09:27:29 +0800 Subject: [PATCH] new instantiated nodes should clean it's fileId before adding to other prefabs. (#2753) --- cocos2d/core/utils/base-node.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js index dc89a26618..0f68ae49c1 100644 --- a/cocos2d/core/utils/base-node.js +++ b/cocos2d/core/utils/base-node.js @@ -1107,8 +1107,11 @@ var BaseNode = cc.Class({ var myPrefabInfo = this._prefab; if (myPrefabInfo) { if (newPrefabRoot) { - // change prefab - _Scene.PrefabUtils.linkPrefab(newPrefabRoot._prefab.asset, newPrefabRoot, this); + if (myPrefabInfo.root !== newPrefabRoot) { + // change prefab + _Scene.PrefabUtils.unlinkPrefab(this); + _Scene.PrefabUtils.linkPrefab(newPrefabRoot._prefab.asset, newPrefabRoot, this); + } } else if (myPrefabInfo.root !== this) { // detach from prefab