More issues on 2018.3.... Value cannot be null. Parameter name: key

Apart of the error "InvalidCastException: Specified cast is not valid." that we mentioned on this thread:
https://opsive.com/forum/index.php?...errors-when-exported-and-added-to-prefab.648/

Now I have the following error when I'm lucky and my tree doesn't disappear as mentioned above. And it's that when I enter in Play mode most of the variables of the Tree lose their reference, as if they were not assigned, but they are ok on the editor. It gets a red mark and a red error list on the behavior Editor. The loop error on the console is the following:

ArgumentNullException: Value cannot be null.
Parameter name: key
System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
BehaviorDesigner.Runtime.TaskUtility.GetTypeWithinAssembly (System.String typeName) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.Tasks.UltimateCharacterController.StartStopAbility.OnStart () (at Assets/Behavior Designer/Integrations/UltimateCharacterController/Scripts/Tasks/StartStopAbility.cs:38)
BehaviorDesigner.Runtime.BehaviorManager.PushTask (BehaviorDesigner.Runtime.BehaviorManager+BehaviorTree behaviorTree, System.Int32 taskIndex, System.Int32 stackIndex) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.BehaviorManager.RunTask (BehaviorDesigner.Runtime.BehaviorManager+BehaviorTree behaviorTree, System.Int32 taskIndex, System.Int32 stackIndex, BehaviorDesigner.Runtime.Tasks.TaskStatus previousStatus) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.BehaviorManager.RunParentTask (BehaviorDesigner.Runtime.BehaviorManager+BehaviorTree behaviorTree, System.Int32 taskIndex, System.Int32& stackIndex, BehaviorDesigner.Runtime.Tasks.TaskStatus status) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.BehaviorManager.RunTask (BehaviorDesigner.Runtime.BehaviorManager+BehaviorTree behaviorTree, System.Int32 taskIndex, System.Int32 stackIndex, BehaviorDesigner.Runtime.Tasks.TaskStatus previousStatus) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.BehaviorManager.RunParentTask (BehaviorDesigner.Runtime.BehaviorManager+BehaviorTree behaviorTree, System.Int32 taskIndex, System.Int32& stackIndex, BehaviorDesigner.Runtime.Tasks.TaskStatus status) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.BehaviorManager.RunTask (BehaviorDesigner.Runtime.BehaviorManager+BehaviorTree behaviorTree, System.Int32 taskIndex, System.Int32 stackIndex, BehaviorDesigner.Runtime.Tasks.TaskStatus previousStatus) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.BehaviorManager.RunParentTask (BehaviorDesigner.Runtime.BehaviorManager+BehaviorTree behaviorTree, System.Int32 taskIndex, System.Int32& stackIndex, BehaviorDesigner.Runtime.Tasks.TaskStatus status) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.BehaviorManager.RunTask (BehaviorDesigner.Runtime.BehaviorManager+BehaviorTree behaviorTree, System.Int32 taskIndex, System.Int32 stackIndex, BehaviorDesigner.Runtime.Tasks.TaskStatus previousStatus) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.BehaviorManager.Tick (BehaviorDesigner.Runtime.BehaviorManager+BehaviorTree behaviorTree) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.BehaviorManager.Tick () (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.BehaviorManager.Update () (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)

So basically I can't work with Behavior Trees on 20108.3 (last BD version installed) because either the problem on the thread above that the tree dissapears with the "InvalidCastException" error or if I'm lucky and finally I get the tree, once I enter in play mode I get this error. I have stay with these errors for lot of hours / days and I have tried on Windows, Mac and in new fresh projects also.
 

Justin

Administrator
Staff member
With both this one and your other post can you list the steps to reproduce or send me a repro scene via PM or email? It's extremely tough to say the cause with just a stack trace.
 
It's quite easy to reproduce as it always happens after some time editing the prefabs. I have tried in different computers with different versions of 2018.3
I've just opened a new fresh project with 2018.3.3f1(It's last version, I tried with this just in case it's better result) on Mac (I mostly work on Windows, but I gave Mac a try)

You install:
- BD 1.6.1
- Movement Pack
- Ultimate Character Controller ( I installed first Third Person and then First Person)
- BD UCC Integration.

-Open one of the 4 demo scenes in BD/Integrations/Ultimate (for instance ThirdPersonShooterScene)
-Make Agent Nolan Prefab.
-Add 3 or 4 instances of the Age Nolan Prefab in Scene.
-Start editing the prefabs and the instances and after 4 or 5 times editing the Trees on the prefab / instance and pressing the OPEN button you'll get the tree empty on some of the instances or prefabs (mostly on the prefabs).
- Save the Tree on your assets folder, (I saved on the same folder prefab than Agent Alan)
- Add the External Tree to the External Behaviour field on the Behaviour Tree Component on the Prefab.
-Again start editing the prefabs and the instances and after 4 or 5 times editing the Trees on the prefab / instance you'll get the tree empty on some of the instances or prefabs (mostly on the prefabs).
- Same with the external Tree, in case you open / edit it directly on the file.asset

- Have a look a the errors on the console when you press the OPEN button on the Behaviour Tree Name field. This time I got different at the ones I show you before (above and the other thread). See the error bellow.


ArgumentException: Object of type 'UnityEngine.Object' cannot be converted to type 'UnityEngine.GameObject'.
System.RuntimeType.CheckValue (System.Object value, System.Reflection.Binder binder, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
System.Reflection.MonoField.SetValue (System.Object obj, System.Object val, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object value) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
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) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
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) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.JSONDeserialization.DeserializeVariables (BehaviorDesigner.Runtime.IVariableSource variableSource, System.Collections.Generic.Dictionary`2[TKey,TValue] dict, System.Collections.Generic.List`1[T] unityObjects) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.JSONDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, System.Boolean inspectorLoad) (at <6224ec08a63b4190a0704159812b1ad4>:0)
BehaviorDesigner.Editor.BehaviorInspector.DrawInspectorGUI (BehaviorDesigner.Runtime.Behavior behavior, UnityEditor.SerializedObject serializedObject, System.Boolean fromInspector, System.Boolean& externalModification, System.Boolean& showOptions, System.Boolean& showVariables) (at <6224ec08a63b4190a0704159812b1ad4>:0)
BehaviorDesigner.Editor.BehaviorInspector.OnInspectorGUI () (at <6224ec08a63b4190a0704159812b1ad4>:0)
UnityEditor.InspectorWindow.DoOnInspectorGUI (System.Boolean rebuildOptimizedGUIBlock, UnityEditor.Editor editor, System.Boolean wasVisible, UnityEngine.Rect& contentRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1625)
UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
 

Justin

Administrator
Staff member
Can you send me a PM or email with the prefabs and external trees that you created?
 

skatesa207

New member
I had this issue recently, and I found a fix that worked for me.

In the Behavior Designer editor window, at the very top right you should see a preferences option (you might need to maximize window to see this option), go ahead and click on that, and towards the bottom I changed the Serialization from JSON to binary; after changing it I no longer had the issue, and I even changed the Serialization back to JSON to see if the issue was still there and it seemed to completely fix it by simply toggling it to binary.
 
Top