UnitySerializedDictionary
UnitySerializedDictionary copied to clipboard
Enumeration in ScriptableObject
-
Created a
public class UDictionaryStringColor : UDictionary<String, Color>
following the provided code example. -
Created a ScriptableObject class that has a
UDictionaryStringColor
field. -
Objects works and stores values without issues.
-
Try to iterate trough the ScriptableObject field and get an error:
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.Collections.Generic.UDictionary`2+Enumerator[TKey,TValue].MoveNext () (at Library/PackageCache/com.prastiwar.unityserializeddictionary@769342ef7b/Runtime/UDictionary.cs:719)
Update for the ones having the same problem: It works for standard GameObjects but not ScriptableObjects.
The properties for the scriptable object should be verified at this function call (Keys, Values) if it's properly serialized by unity. I'm not familiar with scriptable object serialization but at this point - the enumerator I can't see at which point it can happens, this whole thing is Microsoft implementation so I can assume Unity's serialization is an issue. I don't use Unity anymore (unfortunately no time for that) and can't debug it.
If anyone is able to detect the issue and fix it - pull request is more than welcome :)