UnitySerializedDictionary icon indicating copy to clipboard operation
UnitySerializedDictionary copied to clipboard

Enumeration in ScriptableObject

Open rudamaia opened this issue 3 years ago • 2 comments

  1. Created a public class UDictionaryStringColor : UDictionary<String, Color> following the provided code example. Screen Shot 2022-01-05 at 00 04 34

  2. Created a ScriptableObject class that has a UDictionaryStringColor field.

  3. Objects works and stores values without issues. Screen Shot 2022-01-05 at 00 04 07

  4. Try to iterate trough the ScriptableObject field and get an error: Screen Shot 2022-01-05 at 00 08 32

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)

rudamaia avatar Jan 05 '22 03:01 rudamaia

Update for the ones having the same problem: It works for standard GameObjects but not ScriptableObjects.

rudamaia avatar Jan 05 '22 15:01 rudamaia

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 :)

Prastiwar avatar Sep 04 '22 17:09 Prastiwar