'Data layout mismatch' Error Due to Changing Script Namespace

Issue #343 resolved
Belome created an issue

Hi, I'm having an issue that is blocking development. I posted this issue in the Unity thread, but figured I'd post here in hopes of getting help.

I renamed my main namespace for my game scripts from Foo to Bar, and now I get Data layout mismatch errors. I also tried replacing the old namespace in .asset files containing string names of scripts, which did not change anything. I also tried removing the assemblies and using the source scripts so that I could log which serialized asset/node is causing the issue, and I think that the ExitNode() throws the error when called for the 'comparer' node, but when I look at the source for the problem serialized asset/node, I'm not sure what I can do to fix it.

Here is the full stack trace:

Data layout mismatch; skipping past array boundary when exiting node.
UnityEngine.Debug:LogError(Object)
Sirenix.Serialization.CustomLogger:LogError(String) (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization.Config/CustomLogger.cs:53)
Sirenix.Serialization.DebugContext:LogError(String) (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization/Misc/SerializationConfig.cs:193)
Sirenix.Serialization.BinaryDataReader:ExitNode() (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization/DataReaderWriters/Binary/BinaryDataReader.cs:486)
Sirenix.Serialization.ComplexTypeSerializer`1:ReadValue(IDataReader) (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization/Serializers/ComplexTypeSerializer.cs:362)
Sirenix.Serialization.DictionaryFormatter`2:DeserializeImplementation(Dictionary`2&, IDataReader) (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization/Formatters/DictionaryFormatter.cs:70)
Sirenix.Serialization.BaseFormatter`1:Deserialize(IDataReader) (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization/Formatters/BaseFormatter.cs:172)
Sirenix.Serialization.ComplexTypeSerializer`1:ReadValue(IDataReader) (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization/Serializers/ComplexTypeSerializer.cs:332)
Sirenix.Serialization.Serializer`1:ReadValueWeak(IDataReader) (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization/Serializers/Serializer.cs:249)
Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, IDataReader) (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization/Utilities/UnitySerializationUtility.cs:1433)
Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, Byte[]&, List`1&, DataFormat, DeserializationContext) (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization/Utilities/UnitySerializationUtility.cs:1346)
Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, SerializationData&, DeserializationContext, Boolean, List`1) (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization/Utilities/UnitySerializationUtility.cs:1079)
Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, SerializationData&, DeserializationContext) (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization/Utilities/UnitySerializationUtility.cs:994)
Sirenix.OdinInspector.SerializedScriptableObject:UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize() (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization/Unity Integration/SerializedScriptableObject.cs:24)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

Any idea on what is causing the issue? Are there specific steps that I need to take when renaming the namespace of a script that is being referenced by a serialized object? Maybe changing the string resulted in a different hashed guid, and the old hash wasn't replaced? Or maybe the different serialized asset byte size was cached somewhere, and the namespace string length change brough it out of sync with the cached length? Grasping at straws here, but trying to figure out how I can fix this.

On OSX, Unity 2018.1.1f1, 1.0.6.9.

Thanks

Comments (9)

  1. Tor Esa Vestergaard
    • changed status to open

    Could you please post a .asset file containing some serialized data which is causing this issue, along with the old full name and the new full name of the renamed type? I'll see if I can replicate it using that asset's serialized data and try to figure out what's going on.

    This is a case that should ideally just work (if the type's name itself didn't change), and even if the rename caused types to go missing, it certainly shouldn't be causing a data layout mismatch, as that implies an error in the skipping code.

  2. Belome reporter

    I am changing the script namespace and not touching any of the serialized assets, which still results in the Data layout mismatch error for some of my SerializedScriptableObjects that contain a dictionary. If I instead edit the assets and replace all the old namespace strings with the new namespace via gsed (I'm on OSX), I still get the Data layout mismatch error.

    Here is one example SerializedScriptableObject that immediately causes the error after just the script namespace change, and not being touched.

    %YAML 1.1
    %TAG !u! tag:unity3d.com,2011:
    --- !u!114 &11400000
    MonoBehaviour:
      m_ObjectHideFlags: 0
      m_PrefabParentObject: {fileID: 0}
      m_PrefabInternal: {fileID: 0}
      m_GameObject: {fileID: 0}
      m_Enabled: 1
      m_EditorHideFlags: 0
      m_Script: {fileID: 11500000, guid: e0c6ed9112b904204b5493a24a9bc437, type: 3}
      m_Name: GlobalSprites
      m_EditorClassIdentifier: 
      serializationData:
        SerializedFormat: 2
        SerializedBytes: 
        ReferencedUnityObjects:
        - {fileID: 21300000, guid: 4e3d9cbf3b89d487eb1db83a02344562, type: 3}
        - {fileID: 21300000, guid: 589b5c8f9329e45439c6998db955b23f, type: 3}
        - {fileID: 21300000, guid: fb3b15b7e428843b3a21b4958748dc7b, type: 3}
        - {fileID: 21300000, guid: 44a054df1702e39458b7072b08d0f212, type: 3}
        - {fileID: 21300000, guid: 9e0963e03ea4c4597806e9f77cf6c7c7, type: 3}
        - {fileID: 21300000, guid: 9618ecdb3c80c4f0184d8bffa58282ef, type: 3}
        - {fileID: 21300000, guid: b5eb03ddf28834e9288e0dbebc112ee5, type: 3}
        - {fileID: 21300000, guid: 629c00b2a0adf461d829b1044319b593, type: 3}
        - {fileID: 21300000, guid: 070b72f5b453249379eead5af83e5fb4, type: 3}
        - {fileID: 21300000, guid: 51620cbaeda294bc99c1dff8f3df3529, type: 3}
        - {fileID: 21300000, guid: 5d6b3df06937b4c8abb90c61bb56f756, type: 3}
        - {fileID: 21300000, guid: f270334ad3c244a7590f742ee5b4a374, type: 3}
        - {fileID: 21300000, guid: a39d731a2de6041ebac7f9031fbfd3c5, type: 3}
        - {fileID: 21300000, guid: 35bbfb6a9d163418b8ee58fe974a5e1d, type: 3}
        - {fileID: 21300000, guid: 692fee6b2edd64a22b465803305eee2b, type: 3}
        - {fileID: 21300000, guid: be8b1e152b68140b59c423fbf33386ab, type: 3}
        - {fileID: 21300000, guid: 0ba39852c1fd249799f151709142dbd6, type: 3}
        - {fileID: 21300000, guid: eefe9c874d1b64421a908329e3aa139e, type: 3}
        - {fileID: 21300000, guid: d75cd6b0e5c5345f4adf26254c7a17c9, type: 3}
        - {fileID: 21300000, guid: 71a762e51d3b74ec39b3bf076f7bc6de, type: 3}
        - {fileID: 21300000, guid: b734e6998eabc48b5bf7f166db8ab65d, type: 3}
        - {fileID: 21300000, guid: d193492c30711474c8bee74659045eb6, type: 3}
        - {fileID: 21300000, guid: 3f6bdbcc0f966487c8c32c1e2ce5e115, type: 3}
        - {fileID: 21300000, guid: 3ee167a81aa0c4b59a3fcb9e53e18cc9, type: 3}
        - {fileID: 21300000, guid: 707b9dff938c246a6a06742e0dd77cf8, type: 3}
        - {fileID: 21300000, guid: fb008e7680c624726867277f121fe6f7, type: 3}
        - {fileID: 21300000, guid: e6917a316e4ed41bd92f528c81ca16f8, type: 3}
        - {fileID: 21300000, guid: e889443de23b9430080bc77eb17a02f7, type: 3}
        - {fileID: 21300000, guid: 9607e9ee15f1448dbb5ca5d32738fc0a, type: 3}
        - {fileID: 21300000, guid: b5805e38caea5419ea87563af3949979, type: 3}
        - {fileID: 21300000, guid: d6f545207010f433e81aafc57eb077ce, type: 3}
        - {fileID: 21300000, guid: 887f2bb84faf445f5a824fbae443ae6f, type: 3}
        - {fileID: 21300000, guid: 3219d6402bb864d61a92d1d3ee45d688, type: 3}
        - {fileID: 21300000, guid: 563e95bc302d44505968d654c095d9f9, type: 3}
        - {fileID: 21300000, guid: a0fea043376864f4795eeed924139bef, type: 3}
        - {fileID: 21300000, guid: f3660404ceb254a9790de9bcac83b7e1, type: 3}
        - {fileID: 21300000, guid: c45230bfae7184dd1aab6eaca3487977, type: 3}
        - {fileID: 21300000, guid: 8e99e3a0018b142668efe0a3fb0dc9db, type: 3}
        - {fileID: 21300000, guid: cdf3f07b772f64107a8aa7bf3d3d210b, type: 3}
        - {fileID: 21300000, guid: 4357cfd911d154b988a0927d372b8079, type: 3}
        - {fileID: 21300000, guid: 30e512c2c3fc54fd4bff3648690c9d0e, type: 3}
        - {fileID: 21300000, guid: 18289b8a615c94245b351d56ec74d1c0, type: 3}
        - {fileID: 21300000, guid: d2cc1b1a403f9461c923e7c3d9c79f13, type: 3}
        - {fileID: 21300000, guid: 20eaa73ab4fd541bbaf6d55cede1f7cd, type: 3}
        - {fileID: 21300000, guid: a98dc842b8c554476a081289f262efa0, type: 3}
        - {fileID: 21300000, guid: 31348a8190a7343a2b627c7a37952d4b, type: 3}
        - {fileID: 21300000, guid: 936df5098ee074b4a8fa59bc7d9d702a, type: 3}
        - {fileID: 21300000, guid: cc9e0c70dbe63461ab24107519c9778f, type: 3}
        - {fileID: 21300000, guid: 84ac07b0b3d4144abb20797569b5e927, type: 3}
        - {fileID: 21300000, guid: fd64932f65bc74e2289e26590fe5405c, type: 3}
        - {fileID: 21300000, guid: 7fb872cb434954435b52c285298e1e9f, type: 3}
        - {fileID: 21300000, guid: f4657ef2b459f4e318d7a78192e35ed8, type: 3}
        - {fileID: 21300000, guid: 0ca7294956609469fa78fc6807081450, type: 3}
        - {fileID: 21300000, guid: 6e0f19056982c460e8ece78052678cd1, type: 3}
        SerializedBytesString: 
        Prefab: {fileID: 0}
        PrefabModificationsReferencedUnityObjects: []
        PrefabModifications: []
        SerializationNodes:
        - Name: PowerUpIcons
          Entry: 7
          Data: 0|System.Collections.Generic.Dictionary`2[[System.Int32, mscorlib],[UnityEngine.Sprite,
            UnityEngine.CoreModule]], mscorlib
        - Name: comparer
          Entry: 7
          Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.Int32,
            mscorlib]], mscorlib
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 12
          Data: 5
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 16
        - Name: 
          Entry: 10
          Data: 0
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 32
        - Name: 
          Entry: 10
          Data: 0
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 64
        - Name: 
          Entry: 10
          Data: 0
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 128
        - Name: 
          Entry: 10
          Data: 1
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 256
        - Name: 
          Entry: 10
          Data: 2
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: AchievementIcons
          Entry: 7
          Data: 2|System.Collections.Generic.Dictionary`2[[Foo.Scripts.Achievements.AchievementType,
            Assembly-CSharp],[UnityEngine.Sprite, UnityEngine.CoreModule]], mscorlib
        - Name: comparer
          Entry: 7
          Data: 3|System.Collections.Generic.EnumEqualityComparer`1[[Foo.Scripts.Achievements.AchievementType,
            Assembly-CSharp]], mscorlib
        - Name: 
          Entry: 12
          Data: 0
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 12
          Data: 10
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 5
        - Name: 
          Entry: 10
          Data: 3
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 10
        - Name: 
          Entry: 10
          Data: 3
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 20
        - Name: 
          Entry: 10
          Data: 3
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 30
        - Name: 
          Entry: 10
          Data: 3
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 100
        - Name: 
          Entry: 10
          Data: 3
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 110
        - Name: 
          Entry: 10
          Data: 3
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 200
        - Name: 
          Entry: 10
          Data: 3
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 0
        - Name: 
          Entry: 10
          Data: 4
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 210
        - Name: 
          Entry: 10
          Data: 3
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 220
        - Name: 
          Entry: 10
          Data: 3
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: RewardIcons
          Entry: 7
          Data: 4|System.Collections.Generic.Dictionary`2[[Foo.Scripts.Achievements.RewardType,
            Assembly-CSharp],[UnityEngine.Sprite, UnityEngine.CoreModule]], mscorlib
        - Name: comparer
          Entry: 7
          Data: 5|System.Collections.Generic.EnumEqualityComparer`1[[Foo.Scripts.Achievements.RewardType,
            Assembly-CSharp]], mscorlib
        - Name: 
          Entry: 12
          Data: 0
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 12
          Data: 2
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 10
        - Name: 
          Entry: 10
          Data: 4
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 0
        - Name: 
          Entry: 10
          Data: 3
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: ItemTypes
          Entry: 7
          Data: 6|System.Collections.Generic.Dictionary`2[[Foo.Scripts.Inventory.ItemType,
            Assembly-CSharp],[UnityEngine.Sprite, UnityEngine.CoreModule]], mscorlib
        - Name: comparer
          Entry: 7
          Data: 7|System.Collections.Generic.EnumEqualityComparer`1[[Foo.Scripts.Inventory.ItemType,
            Assembly-CSharp]], mscorlib
        - Name: 
          Entry: 12
          Data: 0
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 12
          Data: 4
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 1
        - Name: 
          Entry: 10
          Data: 5
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 2
        - Name: 
          Entry: 10
          Data: 6
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 3
        - Name: 
          Entry: 10
          Data: 7
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 4
        - Name: 
          Entry: 10
          Data: 8
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: Weapons
          Entry: 7
          Data: 8|System.Collections.Generic.Dictionary`2[[Foo.Scripts.Weapons.ProjectilePrefabType,
            Assembly-CSharp],[UnityEngine.Sprite, UnityEngine.CoreModule]], mscorlib
        - Name: comparer
          Entry: 7
          Data: 9|System.Collections.Generic.EnumEqualityComparer`1[[Foo.Scripts.Weapons.ProjectilePrefabType,
            Assembly-CSharp]], mscorlib
        - Name: 
          Entry: 12
          Data: 0
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 12
          Data: 18
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 1
        - Name: 
          Entry: 10
          Data: 9
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 30
        - Name: 
          Entry: 10
          Data: 10
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 31
        - Name: 
          Entry: 10
          Data: 11
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 32
        - Name: 
          Entry: 10
          Data: 12
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 33
        - Name: 
          Entry: 10
          Data: 13
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 34
        - Name: 
          Entry: 10
          Data: 14
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 40
        - Name: 
          Entry: 10
          Data: 15
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 41
        - Name: 
          Entry: 10
          Data: 16
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 42
        - Name: 
          Entry: 10
          Data: 17
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 43
        - Name: 
          Entry: 10
          Data: 18
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 44
        - Name: 
          Entry: 10
          Data: 19
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 60
        - Name: 
          Entry: 10
          Data: 20
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 61
        - Name: 
          Entry: 10
          Data: 21
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 62
        - Name: 
          Entry: 10
          Data: 22
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 63
        - Name: 
          Entry: 10
          Data: 23
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 64
        - Name: 
          Entry: 10
          Data: 24
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 65
        - Name: 
          Entry: 10
          Data: 25
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 4
        - Name: 
          Entry: 10
          Data: 26
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: Armor
          Entry: 7
          Data: 10|System.Collections.Generic.Dictionary`2[[Foo.Scripts.Vehicles.ArmorPrefabType,
            Assembly-CSharp],[UnityEngine.Sprite, UnityEngine.CoreModule]], mscorlib
        - Name: comparer
          Entry: 7
          Data: 11|System.Collections.Generic.EnumEqualityComparer`1[[Foo.Scripts.Vehicles.ArmorPrefabType,
            Assembly-CSharp]], mscorlib
        - Name: 
          Entry: 12
          Data: 0
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 12
          Data: 9
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 1
        - Name: 
          Entry: 10
          Data: 27
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 2
        - Name: 
          Entry: 10
          Data: 28
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 3
        - Name: 
          Entry: 10
          Data: 29
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 4
        - Name: 
          Entry: 10
          Data: 30
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 5
        - Name: 
          Entry: 10
          Data: 31
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 6
        - Name: 
          Entry: 10
          Data: 32
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 7
        - Name: 
          Entry: 10
          Data: 33
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 8
        - Name: 
          Entry: 10
          Data: 34
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 9
        - Name: 
          Entry: 10
          Data: 35
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: Tires
          Entry: 7
          Data: 12|System.Collections.Generic.Dictionary`2[[Foo.Scripts.Vehicles.TirePrefabType,
            Assembly-CSharp],[UnityEngine.Sprite, UnityEngine.CoreModule]], mscorlib
        - Name: comparer
          Entry: 7
          Data: 13|System.Collections.Generic.EnumEqualityComparer`1[[Foo.Scripts.Vehicles.TirePrefabType,
            Assembly-CSharp]], mscorlib
        - Name: 
          Entry: 12
          Data: 0
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 12
          Data: 11
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 10
        - Name: 
          Entry: 10
          Data: 36
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 1
        - Name: 
          Entry: 10
          Data: 37
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 20
        - Name: 
          Entry: 10
          Data: 38
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 30
        - Name: 
          Entry: 10
          Data: 39
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 40
        - Name: 
          Entry: 10
          Data: 40
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 50
        - Name: 
          Entry: 10
          Data: 41
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 60
        - Name: 
          Entry: 10
          Data: 42
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 70
        - Name: 
          Entry: 10
          Data: 43
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 80
        - Name: 
          Entry: 10
          Data: 44
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 90
        - Name: 
          Entry: 10
          Data: 45
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 100
        - Name: 
          Entry: 10
          Data: 46
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: Rams
          Entry: 7
          Data: 14|System.Collections.Generic.Dictionary`2[[Foo.Scripts.Vehicles.RamPrefabType,
            Assembly-CSharp],[UnityEngine.Sprite, UnityEngine.CoreModule]], mscorlib
        - Name: comparer
          Entry: 7
          Data: 15|System.Collections.Generic.EnumEqualityComparer`1[[Foo.Scripts.Vehicles.RamPrefabType,
            Assembly-CSharp]], mscorlib
        - Name: 
          Entry: 12
          Data: 0
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 12
          Data: 7
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 1
        - Name: 
          Entry: 10
          Data: 47
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 10
        - Name: 
          Entry: 10
          Data: 48
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 20
        - Name: 
          Entry: 10
          Data: 49
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 30
        - Name: 
          Entry: 10
          Data: 50
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 40
        - Name: 
          Entry: 10
          Data: 51
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 50
        - Name: 
          Entry: 10
          Data: 52
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 7
          Data: 
        - Name: 
          Entry: 3
          Data: 60
        - Name: 
          Entry: 10
          Data: 53
        - Name: 
          Entry: 8
          Data: 
        - Name: 
          Entry: 13
          Data: 
        - Name: 
          Entry: 8
          Data: 
      AllyIndicator: {fileID: 21300000, guid: 1dcb509ddef404139a6c74a7bb06015c, type: 3}
      EnemyIndicator: {fileID: 21300000, guid: 52748616b4a984bf5bf2cc135b6b232b, type: 3}
    

    This asset still has the old foo namespace as I left it untouched. When renaming my scripts to the new bar namespace, I get the error.

    The error is thrown after comparer node of the serialized dictionary below, I believe. I don't know if there is something special about this node that causes the Data layout mismatch error while the other ones before it don't.

        - Name: Rams
          Entry: 7
          Data: 14|System.Collections.Generic.Dictionary`2[[Foo.Scripts.Vehicles.RamPrefabType,
            Assembly-CSharp],[UnityEngine.Sprite, UnityEngine.CoreModule]], mscorlib
        - Name: comparer
          Entry: 7
          Data: 15|System.Collections.Generic.EnumEqualityComparer`1[[Foo.Scripts.Vehicles.RamPrefabType,
            Assembly-CSharp]], mscorlib
    

    I found that this node is problematic by adding a log at line 362 of ComplexTypeSerializer, and then seeing when the Data layout mismatch error is then thrown:

                                    if (exitNode)
                                    {
                                        context.Config.DebugContext.LogError("exit node: " + name);
                                        reader.ExitNode();
                                    }
    

    My Git diffs don't provide any useful information, aside from confirming the perfect namespace string replacement.

    On one scene, the Data layout mismatch error only occurs at runtime. Also, I am able to inspect my SerializedScriptableObjects just fine in the Inspector, even the one causing Data layout mismatch error at runtime.

    Is the deserializer parsing the strings and then using reflection to get the type, or is there some sort of dictionary mapping strings to types?

  3. Tor Esa Vestergaard

    Thank you, this is something I can use to debug it with - I already have a suspicion as to what may be happening just from looking at the data. I'm taking a look at it now, and will let you know what I find out.

  4. Tor Esa Vestergaard

    This is quite strange - I simply cannot get this to replicate, even when directly using your data and setting up all the types properly so that I can inspect all the dictionaries properly in the inspector. When I perform the namespace rename (and only that, no renaming in the asset file), nothing happens. I never get any errors or warnings, and it simply works and deserializes exactly as it usually would. (My theory turned out to be wrong, as far as I could tell - everything did as it should when I stepped through the code.)

    If it's not too much trouble, would it be possible for you to send me a small demo project that reliably replicates this issue?

  5. Belome reporter

    Actually, I ended up changing the Editor->Asset Serialization mode to binary, and then back to text, and now everything works fine! Hopefully anyone else who encounters the Data layout mismatch error can also fix it by toggling the serialization mode to force re-serialization. Thanks for taking the time to help debug the issue!

  6. Belome reporter

    Toggling the Editor->Asset Serialization mode forced re-serialization, which fixed the 'Data layout mismatch` errors.

  7. Tor Esa Vestergaard

    Great! I should still like to find out what the cause of the issue was, as you shouldn't have entered such an invalid state in the first place. If you ever do discover a way to cause it to happen again, please do let us know :)

  8. Log in to comment