new instantiated nodes should clean it's fileId before adding to other prefabs. (#2753)

This commit is contained in:
Jare Guo
2018-05-29 09:27:29 +08:00
committed by pandamicro
parent 9029fe0447
commit 92e99f3038
+5 -2
View File
@@ -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