Browse Source

Scene saving/loading no longer throws exception due to game object handles in prefab diff generation

BearishSun 10 years ago
parent
commit
5aadba0d04
2 changed files with 5 additions and 1 deletions
  1. 1 1
      BansheeCore/Include/BsPrefabDiff.h
  2. 4 0
      SBansheeEngine/Source/BsManagedDiff.cpp

+ 1 - 1
BansheeCore/Include/BsPrefabDiff.h

@@ -106,7 +106,7 @@ namespace BansheeEngine
 		 *
 		 * @note	This is a temporary action and should be undone by calling "restoreInstanceIds" and providing 
 		 *			it with the output of this method. 
-		 * @par		By doing this before calling "diff" we ensure that any game object handles pointing to objects 
+		 * @par		By doing this before calling ::generateDiff we ensure that any game object handles pointing to objects 
 		 *			within the prefab instance hierarchy aren't recorded by the diff system, since we want those to 
 		 *			remain as they are after applying the diff.
 		 */

+ 4 - 0
SBansheeEngine/Source/BsManagedDiff.cpp

@@ -3,6 +3,7 @@
 #include "BsBinarySerializer.h"
 #include "BsMemorySerializer.h"
 #include "BsManagedSerializableObject.h"
+#include "BsGameObjectManager.h"
 #include "BsRTTIType.h"
 
 namespace BansheeEngine
@@ -12,8 +13,11 @@ namespace BansheeEngine
 	{
 		BinarySerializer bs;
 
+		// Need to call GameObjectManager because GameObject handles call it during deserialization, but we don't really need it
+		GameObjectManager::instance().startDeserialization();
 		SPtr<ManagedSerializableObject> orgObj = std::static_pointer_cast<ManagedSerializableObject>(bs._decodeIntermediate(orgSerzObj));
 		SPtr<ManagedSerializableObject> newObj = std::static_pointer_cast<ManagedSerializableObject>(bs._decodeIntermediate(newSerzObj));
+		GameObjectManager::instance().endDeserialization();
 
 		ManagedSerializableDiffPtr diff = ManagedSerializableDiff::create(orgObj, newObj);
 		if (diff == nullptr)