I've been getting NullReferenceException errors related to serialization in Behavior Designer, in Unity 2018.4.
This appears to be a similar error to the one posted here last year, but with slightly different context.
I was using BD 1.5.7, and upgraded the project's Scripting Runtime Version from .NET 3.5 Equivalent to .NET 4.x Equivalent.
After that upgrade, I began getting NullReferenceExceptions from Behavior Designer on start up, opening the designer window, runtime, etc.
I then updated BD from 1.5.7 to 1.6.2 to see if that would alleviate the issue and it did not.
Not sure how to fix the issue. (I also have the BD Formations, Movement, and Tactical packages in my project but have not attempted upgrading or modifying them)
This appears to be a similar error to the one posted here last year, but with slightly different context.
I was using BD 1.5.7, and upgraded the project's Scripting Runtime Version from .NET 3.5 Equivalent to .NET 4.x Equivalent.
After that upgrade, I began getting NullReferenceExceptions from Behavior Designer on start up, opening the designer window, runtime, etc.
I then updated BD from 1.5.7 to 1.6.2 to see if that would alleviate the issue and it did not.
Not sure how to fix the issue. (I also have the BD Formations, Movement, and Tactical packages in my project but have not attempted upgrading or modifying them)
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 <00cb1070d60241ceb207182662d41ddd>:0)
BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <00cb1070d60241ceb207182662d41ddd>:0)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <00cb1070d60241ceb207182662d41ddd>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, System.Boolean inspectorLoad) (at <3275963b2fca4f2ca123754bd86fc27f>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.UpdateTree (System.Boolean firstLoad) (at <3275963b2fca4f2ca123754bd86fc27f>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.OnSelectionChange () (at <3275963b2fca4f2ca123754bd86fc27f>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <d7ac571ca2d04b2f981d0d886fa067cf>: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 <d7ac571ca2d04b2f981d0d886fa067cf>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:342)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:336)
UnityEditor.HostView.OnSelectionChange () (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:199)
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 <8273d6b105784beab3b1f76a8d030c0c>:0)
BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <8273d6b105784beab3b1f76a8d030c0c>:0)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <8273d6b105784beab3b1f76a8d030c0c>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, System.Boolean inspectorLoad) (at <0f49ef0acdbd44f8a5303100d11f8912>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.UpdateTree (System.Boolean firstLoad) (at <0f49ef0acdbd44f8a5303100d11f8912>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.OnGUI () (at <0f49ef0acdbd44f8a5303100d11f8912>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <d7ac571ca2d04b2f981d0d886fa067cf>: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 <d7ac571ca2d04b2f981d0d886fa067cf>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:342)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:336)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:310)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect, System.Boolean customBorder, System.Boolean floatingWindow, System.Boolean isBottomTab) (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:361)
UnityEditor.DockArea.OldOnGUI () (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:320)
UnityEngine.Experimental.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:244)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)