NPE when loading task through Editor after upgrade

thiagolr

New member
I'm trying to edit my behavior after upgrading both Unity and Behavior Designer from a very old version (from around May 2018).

Behavior Designer: 1.6.3
Unity Version: 2019.2.17f1

Code:
NullReferenceException: Object reference not set to an instance of an object
BinaryDeserialization.LoadTask (BehaviorDesigner.Runtime.TaskSerializationData taskSerializationData, BehaviorDesigner.Runtime.FieldSerializationData fieldSerializationData, System.Collections.Generic.List`1[BehaviorDesigner.Runtime.Tasks.Task]& taskList, BehaviorDesigner.Runtime.BehaviorSource& behaviorSource) (at <20126bbe51eb4fb0864ac4163de1de6e>:0)
BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <20126bbe51eb4fb0864ac4163de1de6e>:0)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <20126bbe51eb4fb0864ac4163de1de6e>:0)
BehaviorDesigner.Runtime.BehaviorSource.GetAllVariables () (at <20126bbe51eb4fb0864ac4163de1de6e>:0)
BehaviorDesigner.Editor.ExternalBehaviorInspector.DrawInspectorGUI (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean fromInspector, System.Boolean& showVariables) (at <16f31d5e691e49bb8277da3cfa8e17e2>:0)
BehaviorDesigner.Editor.ExternalBehaviorInspector.OnInspectorGUI () (at <16f31d5e691e49bb8277da3cfa8e17e2>:0)
UnityEditor.UIElements.InspectorElement+<CreateIMGUIInspectorFromEditor>c__AnonStorey1.<>m__0 () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:501)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)


1578832154912.png
 
What version of Behavior Designer was that tree created with? Depending on how old it is you may need to use an older version of Behavior Designer to open it. Do you have a prior version in source control that you can try?
 
This was already happening with the older version (from around May 2018), the issue started when I upgraded the Unity version to the latest. Then when the issue started I upgraded to Behavior Designer latest version.

This is the error from the old Behavior Tree version:

Code:
NullReferenceException: Object reference not set to an instance of an object
BinaryDeserialization.LoadTask (BehaviorDesigner.Runtime.TaskSerializationData taskSerializationData, BehaviorDesigner.Runtime.FieldSerializationData fieldSerializationData, System.Collections.Generic.List`1[BehaviorDesigner.Runtime.Tasks.Task]& taskList, BehaviorDesigner.Runtime.BehaviorSource& behaviorSource) (at <7ca38c0abe114e0fb0b2748158885a58>:0)
BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <7ca38c0abe114e0fb0b2748158885a58>:0)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <7ca38c0abe114e0fb0b2748158885a58>:0)
BehaviorDesigner.Editor.GraphDesigner.Load (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, UnityEngine.Vector2 nodePosition) (at <4227664a44a44d05890c4625b6ae7313>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, System.Boolean inspectorLoad) (at <4227664a44a44d05890c4625b6ae7313>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.UpdateTree (System.Boolean firstLoad) (at <4227664a44a44d05890c4625b6ae7313>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.OnSelectionChange () (at <4227664a44a44d05890c4625b6ae7313>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <567df3e0919241ba98db88bec4c6696f>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <567df3e0919241ba98db88bec4c6696f>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <567df3e0919241ba98db88bec4c6696f>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:359)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:353)
UnityEditor.HostView.OnSelectionChange () (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:239)
 
What version of BD did you upgrade from? I'm guessing that when you updated Unity BD didn't support .net 4 and that's the default now for Unity. If you send me your tree I can try to salvage it, but the runtime source is also available if you want to take a closer look.

 
The previous version was 1.5.8, the BD trees are attached, please give it a try! Thanks!
 

Attachments

  • BDFiles.zip
    17.2 KB · Views: 1
Ah, 1.5.8 is extremely old and the serialization has changed a lot since then. Unfortunately I can't recover those with the current version. I wish that the Asset Store had a way to download prior versions but if you incrementally update from 1.5.8 to later versions it should work. If you send an email to support@opsive.com I can send you links to some of the prior versions.
 
I just sent an e-mail to you!

I'm on the Unity latest version and with BD 1.5.8. You are suggesting to upgrade incrementally from this state, is that it? Or do I need to rollback the Unity version as well?
 
Edit: I was just speaking with Justin on Discord and task.OnReset is now being called which causes the error related to Bool nodes posted below. See last line for solution. You will need to apply the same fix to any cool node you want to use until a fix is provided.



I'm having a similar issue with certain node components. I am unable to open any Bool related node in the editor. I get the following error:
Code:
NullReferenceException: Object reference not set to an instance of an object
BehaviorDesigner.Runtime.Tasks.Unity.Math.SetBool.OnReset () (at Assets/Behavior Designer/Runtime/Tasks/Unity/Math/SetBool.cs:20)
BehaviorDesigner.Editor.GraphDesigner.AddNode (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Type type, UnityEngine.Vector2 position) (at <f9cf0791cb17498483e35b4d25a76c02>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.AddTask (System.Type type, System.Boolean useMousePosition) (at <f9cf0791cb17498483e35b4d25a76c02>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.AddTaskCallback (System.Object obj) (at <f9cf0791cb17498483e35b4d25a76c02>:0)
UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, System.Int32 selected) (at C:/buildslave/unity/build/Editor/Mono/GUI/GenericMenu.cs:119)

If I comment out the OnReset method from the SetBool code the Node loads correctly.
 
Hi I have the same problem. Using BD 1.6.4 with Unity 2018.4.13f1 I am an artist not a coder so should I just wait for a fix?
 
This has been fixed and released on the Asset Store - the version number is the same but you should see the update button.
 
Top