Editing a SerializedMonoBehaviour file while in Play Mode throws NullReferenceException

Issue #852 new
Ashton Jenson created an issue

As said in title, this behavior here are the steps to replicate said behavior…

This behavior does not generally break the functionality of the script, but it often “soft resets” it, with behaviors like changing List of Lists Contents. If I can find a good example of this happening in the near future, or if otherwise asked, I will upload the steps to reproduce this specific behavior.

As this only ever happens while editing, it is not often an issue during runtime. However, it is a bit irritating to deal with while debugging.

https://www.youtube.com/watch?v=JzM1cHLm3Xg&ab_channel=Faffy_Waffles

Here is a full error dump:

NullReferenceException: Object reference not set to an instance of an object
System.Collections.Generic.HashSetEqualityComparer1[T].GetHashCode (System.Collections.Generic.HashSet1[T] obj) (at <1e18c5a6594041c9844bfd0b6618ee4a>:0)
System.Collections.Generic.Dictionary2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <6073cf49ed704e958b8a66d540dea948>:0) System.Collections.Generic.Dictionary2[TKey,TValue].set_Item (TKey key, TValue value) (at <6073cf49ed704e958b8a66d540dea948>:0)
Sirenix.Serialization.DictionaryFormatter2[TKey,TValue].DeserializeImplementation (System.Collections.Generic.Dictionary2[TKey,TValue]& value, Sirenix.Serialization.IDataReader reader) (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Core/Formatters/DictionaryFormatter.cs:128)
UnityEngine.Debug:LogException(Exception)
Sirenix.Serialization.CustomLogger:LogException(Exception) (at Y:/Repositories/sirenix-development-framework/Sirenix Solution/Sirenix.Serialization.Config/CustomLogger.cs:67)
Sirenix.Serialization.DebugContext:LogException(Exception) (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Core/Misc/SerializationConfig.cs:252)
Sirenix.Serialization.DictionaryFormatter2:DeserializeImplementation(Dictionary2&, IDataReader) (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Core/Formatters/DictionaryFormatter.cs:137)
Sirenix.Serialization.BaseFormatter1:Deserialize(IDataReader) (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Core/Formatters/BaseFormatter.cs:222) Sirenix.Serialization.ComplexTypeSerializer1:ReadValue(IDataReader) (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Core/Serializers/ComplexTypeSerializer.cs:366)
Sirenix.Serialization.Serializer1:ReadValueWeak(IDataReader) (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Core/Serializers/Serializer.cs:261) Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, IDataReader) (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Unity Integration/UnitySerializationUtility.cs:1881) Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, Byte[]&, List1&, DataFormat, DeserializationContext) (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Unity Integration/UnitySerializationUtility.cs:1730)
Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, SerializationData&, DeserializationContext, Boolean, List`1) (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Unity Integration/UnitySerializationUtility.cs:1415)
Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, SerializationData&, DeserializationContext) (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Unity Integration/UnitySerializationUtility.cs:1312)
Sirenix.OdinInspector.SerializedMonoBehaviour:UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize() (at Y:/Repositories/sirenix-development-framework/OdinSerializer/OdinSerializer/Unity Integration/SerializedUnityObjects/SerializedMonoBehaviour.cs:37)

Comments (5)

  1. Antonio Rafael Antunes Miranda

    Hey 🙂
    could you please include the code of the SerializedMonoBehaviour in question.

  2. Ashton Jenson reporter

    Will do. Its a huge file however (~3000 lines), so I’ll send it as soon as I get rid of unnecessary code that does not reference Odin.

    I’ll also send some other smaller files where the issue is able to be reproduced.

  3. Ashton Jenson reporter

    I’ve also updated Odin to the current 3.0.13, and the error persists there as well.

  4. Log in to comment