Browse Source

Fixed an issue with lists serializing objects

Marko Pintera 11 years ago
parent
commit
d164b7f8dd

+ 1 - 1
MBansheeEngine/DbgComponent.cs

@@ -12,6 +12,6 @@ namespace BansheeEngine
         public DbgComponent2 otherComponent;
         public SceneObject otherSO;
         public int[][][] zeArray;
-        public List<int> zeList;
+        public List<DbgSerzObj> zeList;
     }
 }

+ 8 - 6
MBansheeEngine/Program.cs

@@ -23,12 +23,14 @@ namespace BansheeEngine
             dbgComponent.otherComponent = dbgComponent2;
             dbgComponent.otherSO = otherSO;
             dbgComponent.zeArray = new int[5][][];
-            dbgComponent.zeList = new List<int>();
+            dbgComponent.zeList = new List<DbgSerzObj>();
 
-            dbgComponent.zeList.Add(0);
-            dbgComponent.zeList.Add(0);
-            dbgComponent.zeList.Add(99);
-            dbgComponent.zeList.Add(0);
+            dbgComponent.zeList.Add(new DbgSerzObj());
+            dbgComponent.zeList.Add(new DbgSerzObj());
+            dbgComponent.zeList.Add(new DbgSerzObj());
+            dbgComponent.zeList.Add(new DbgSerzObj());
+
+            dbgComponent.zeList[2].someValue = 101;
 
             for (int i = 0; i < dbgComponent.zeArray.Length; i++)
             {
@@ -45,7 +47,7 @@ namespace BansheeEngine
             for (int i = 0; i < so.GetNumChildren(); i++)
             {
                 SceneObject childSO = so.GetChild(i);
-                reportDbgValue(childSO.GetComponent<DbgComponent>().zeList[2], childSO.GetComponent<DbgComponent>().zeArray[4][1][3], typeof(DbgComponent));
+                reportDbgValue(childSO.GetComponent<DbgComponent>().zeList[2].someValue, childSO.GetComponent<DbgComponent>().zeArray[4][1][3], typeof(DbgComponent));
             }
 
             //Color newColor = Color.red;

+ 2 - 2
SBansheeEngine/Source/BsScriptSerializableDictionary.cpp

@@ -22,7 +22,7 @@ namespace BansheeEngine
 		if(mono_class_is_valuetype(mono_object_get_class(obj)))
 			return ScriptSerializableFieldData::create(mParent->mDictionaryTypeInfo->mKeyType, mono_object_unbox(obj));
 		else
-			return ScriptSerializableFieldData::create(mParent->mDictionaryTypeInfo->mKeyType, obj);
+			return ScriptSerializableFieldData::create(mParent->mDictionaryTypeInfo->mKeyType, &obj);
 	}
 
 	ScriptSerializableFieldDataPtr ScriptSerializableDictionary::Enumerator::getValue() const
@@ -32,7 +32,7 @@ namespace BansheeEngine
 		if(mono_class_is_valuetype(mono_object_get_class(obj)))
 			return ScriptSerializableFieldData::create(mParent->mDictionaryTypeInfo->mValueType, mono_object_unbox(obj));
 		else
-			return ScriptSerializableFieldData::create(mParent->mDictionaryTypeInfo->mValueType, obj);
+			return ScriptSerializableFieldData::create(mParent->mDictionaryTypeInfo->mValueType, &obj);
 	}
 
 	bool ScriptSerializableDictionary::Enumerator::moveNext()

+ 1 - 1
SBansheeEngine/Source/BsScriptSerializableList.cpp

@@ -102,7 +102,7 @@ namespace BansheeEngine
 		if(mono_class_is_valuetype(mono_object_get_class(obj)))
 			return ScriptSerializableFieldData::create(mListTypeInfo->mElementType, mono_object_unbox(obj));
 		else
-			return ScriptSerializableFieldData::create(mListTypeInfo->mElementType, obj);
+			return ScriptSerializableFieldData::create(mListTypeInfo->mElementType, &obj);
 	}
 
 	UINT32 ScriptSerializableList::getLength() const