You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting a NullReferenceException from OnAfterDeserialize method. Here is the full stack trace:
NullReferenceException: Object reference not set to an instance of an object
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
SerializableDictionaryBase`3[TKey,TValue,TValueStorage].OnAfterDeserialize () (at Assets/SerializableDictionary/SerializableDictionary.cs:30)
When debugging the code it seems that both m_keys and m_values contain correct serialized values. From what I was able to find online, this could be somehow connected to the dictionary being accessed from multiple threads, which I'm not sure if it's the case with Unity's serialization system.
Hi!
I could not find where you use a SerializableDictionnary in the links and the first one is not working.
Can you reproduce the error on a more simple example ?
Oh those links point to newest commits and I have changed the implementation since then. Here you can see the new implementation. I've implemented the ISerializationCallbackReceiver myself and different to your implementation inside OnAfterDeserialize I'm creating new instance of dictionary which doesn't throw any exceptions when adding elements to it.
I got this error in the case below:
The dictionary's key is an object that can be null (e.g. Transform)
In a script attached to a gameobject, when dictionary's key is null, it gives this exception while loading the gameobject
I'm getting a NullReferenceException from
OnAfterDeserialize
method. Here is the full stack trace:When debugging the code it seems that both
m_keys
andm_values
contain correct serialized values. From what I was able to find online, this could be somehow connected to the dictionary being accessed from multiple threads, which I'm not sure if it's the case with Unity's serialization system.Here is a link to the source code and a dictionary that is giving me the exception:
Dictionary
Place where it is serialized
The text was updated successfully, but these errors were encountered: