Просмотр исходного кода

Fixing a crash when reverting a prefab (new instance would be registered twice as a child)

BearishSun 9 лет назад
Родитель
Сommit
1da37a01e4
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      Source/BansheeCore/Source/BsPrefabUtility.cpp

+ 3 - 0
Source/BansheeCore/Source/BsPrefabUtility.cpp

@@ -28,6 +28,9 @@ namespace BansheeEngine
 		so->destroyInternal(currentSO, true);
 		so->destroyInternal(currentSO, true);
 
 
 		HSceneObject newInstance = prefabLink->instantiate();
 		HSceneObject newInstance = prefabLink->instantiate();
+
+		// Remove default parent, and replace with original one
+		newInstance->mParent->removeChild(newInstance);
 		newInstance->mParent = parent;
 		newInstance->mParent = parent;
 
 
 		restoreLinkedInstanceData(newInstance, soProxy, linkedInstanceData);
 		restoreLinkedInstanceData(newInstance, soProxy, linkedInstanceData);