[Fixed] Serialization issue (100% in build - on and off in Editor)

MBun

New member
Hi,

I can't figure out why I'm having this error 100% in build and on and off in the editor :

C#:
ArgumentNullException: Value cannot be null.
Parameter name: key
  at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) [0x00008] in <2b3a3162be434770b7a4fac8b896e90c>:0
  at System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value) [0x00000] in <2b3a3162be434770b7a4fac8b896e90c>:0
  at BehaviorDesigner.Runtime.BehaviorSource.SetVariable (System.String name, BehaviorDesigner.Runtime.SharedVariable sharedVariable) [0x0003e] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.JSONDeserialization.DeserializeSharedVariable (System.Collections.Generic.Dictionary`2[TKey,TValue] dict, BehaviorDesigner.Runtime.IVariableSource variableSource, System.Boolean fromSource, System.Collections.Generic.List`1[T] unityObjects) [0x00199] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.JSONDeserialization.ValueToObject (BehaviorDesigner.Runtime.Tasks.Task task, System.Type type, System.Object obj, BehaviorDesigner.Runtime.IVariableSource variableSource, System.Collections.Generic.List`1[T] unityObjects) [0x00015] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.JSONDeserialization.DeserializeObject (BehaviorDesigner.Runtime.Tasks.Task task, System.Object obj, System.Collections.Generic.Dictionary`2[TKey,TValue] dict, BehaviorDesigner.Runtime.IVariableSource variableSource, System.Collections.Generic.List`1[T] unityObjects) [0x00402] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.JSONDeserialization.DeserializeTask (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Collections.Generic.Dictionary`2[TKey,TValue] dict, System.Collections.Generic.Dictionary`2[System.Int32,BehaviorDesigner.Runtime.Tasks.Task]& IDtoTask, System.Collections.Generic.List`1[T] unityObjects) [0x001b4] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.JSONDeserialization.DeserializeTask (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Collections.Generic.Dictionary`2[TKey,TValue] dict, System.Collections.Generic.Dictionary`2[System.Int32,BehaviorDesigner.Runtime.Tasks.Task]& IDtoTask, System.Collections.Generic.List`1[T] unityObjects) [0x0020a] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.JSONDeserialization.DeserializeTask (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Collections.Generic.Dictionary`2[TKey,TValue] dict, System.Collections.Generic.Dictionary`2[System.Int32,BehaviorDesigner.Runtime.Tasks.Task]& IDtoTask, System.Collections.Generic.List`1[T] unityObjects) [0x0020a] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.JSONDeserialization.DeserializeTask (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Collections.Generic.Dictionary`2[TKey,TValue] dict, System.Collections.Generic.Dictionary`2[System.Int32,BehaviorDesigner.Runtime.Tasks.Task]& IDtoTask, System.Collections.Generic.List`1[T] unityObjects) [0x0020a] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.JSONDeserialization.DeserializeTask (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Collections.Generic.Dictionary`2[TKey,TValue] dict, System.Collections.Generic.Dictionary`2[System.Int32,BehaviorDesigner.Runtime.Tasks.Task]& IDtoTask, System.Collections.Generic.List`1[T] unityObjects) [0x0020a] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.JSONDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) [0x0010f] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) [0x0005d] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.Behavior.CheckForSerialization (System.Boolean forceSerialization) [0x0007a] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.Behavior.CheckForSerialization () [0x00000] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.BehaviorManager.LoadBehavior (BehaviorDesigner.Runtime.Behavior behavior, UnityEngine.GameObject behaviorGameObject, System.String gameObjectName, UnityEngine.Transform behaviorTransform) [0x00013] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.BehaviorManager.EnableBehavior (BehaviorDesigner.Runtime.Behavior behavior) [0x00110] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.Behavior.EnableBehavior () [0x00016] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0
  at BehaviorDesigner.Runtime.Behavior.Start () [0x0000b] in <0ee4c5f576c0419f8ca527a83ecdbf9f>:0

I'm using Movement addon and I have a two simple behaviour trees (one is an External BehaviourTree that I placed in Resources folder for tests) on 2 different gameobjects.

I tried toggling back and forth the Serialization from JSON to Binary in the Prefs. I rebooted the Unity project. But still, the issue is still present in the build.

Thanks
 
Next tests - I deleted the External Behaviour tree and recreated all from scratch. In fact, when the bug happens and the playmode is in pause, I could see that there seemed to be a residue of the first tree that I first created and turned to an External tree (the old nodes were even there. Ex : Previously I had a CanSeeObject node and in the External tree, I deleted that for a WithinDistance task. But still, on start I could see those nodes pop in the BD editor on one frame).

Unfortunately, that did not solve my issue.

Next - I'm installing Unity 2020.2.5f1 and I'll test commenting any Get/SetVariable() from my script..
 
That error looks like it is coming from the json serializer. It looks like multiple shared variables with the same name exist. If you look at your json serialization data can you see multiple of the same name
 
I could pin point the double shared variable thanks to you. I had one called playerDetected in the BT and another one in a script with the same name. Many thanks!
 
Top