NullReferenceException in BinaryDeserialization.LoadTask after updated the version

wellplayed

New member
I just updated a project from Unity 5.5.4f1 to 2019.1.1f1 and am trying to update Behavior Designer 1.5.8 to 1.6.2. I have successfully updated and imported the new version, and made sure all the .asset files are serialized to 1.6.2, but I am getting a NullReferenceException when I load a specific Behavior Tree using a Behavior Tree Reference. I have tried re-importing all and that still doesn't work.

I get the NullReferenceException when I call behavior.EnableBehavior().

C#:
var behavior = entity.GetComponent<Behavior>();
if(behavior != null) {
    behavior.EnableBehavior();
    behavior.DisableBehavior();
}
Here is the full output:

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.Runtime.Behavior.CheckForSerialization () (at <8273d6b105784beab3b1f76a8d030c0c>:0)
BehaviorDesigner.Runtime.BehaviorManager.EnableBehavior (BehaviorDesigner.Runtime.Behavior behavior) (at <8273d6b105784beab3b1f76a8d030c0c>:0)
BehaviorDesigner.Runtime.Behavior.EnableBehavior () (at <8273d6b105784beab3b1f76a8d030c0c>:0)
NetworkEnemyFactory.Initialize (UnityEngine.GameObject& instance) (at Assets/[AppAssets]/Scripts/Networking/_Scripts/BOTUScripts/NetworkEnemyFactory.cs:107)
Thank you in advance for any help!
 

wellplayed

New member
Hey Justin,

Thank you for the fast reply.

I imported the BehaviorDesignerRuntimeSource.unitypackage and then the RuntimeSource_Unity_2018_3.unitypackage. Again I am using Unity 2019.1.1f1.

The Task is a custom one that calls a Behavior Tree Reference, I have attached images of the two trees.

The error was on line 319 of BinaryDeserialization.cs

C#:
task.ID = (int)LoadField(fieldSerializationData, fieldIndexMap, typeof(int), "ID", 0, null);

Here is the error output:

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 Assets/Plugins/Behavior Designer/Runtime/BinaryDeserialization.cs:319)
BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at Assets/Plugins/Behavior Designer/Runtime/BinaryDeserialization.cs:124)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at Assets/Plugins/Behavior Designer/Runtime/BehaviorSource.cs:76)
BehaviorDesigner.Runtime.Behavior.CheckForSerialization () (at Assets/Plugins/Behavior Designer/Runtime/Behavior.cs:290)
BehaviorDesigner.Runtime.BehaviorManager.EnableBehavior (BehaviorDesigner.Runtime.Behavior behavior) (at Assets/Plugins/Behavior Designer/Runtime/BehaviorManager.cs:301)
BehaviorDesigner.Runtime.Behavior.EnableBehavior () (at Assets/Plugins/Behavior Designer/Runtime/Behavior.cs:169)
Thanks again for the help!


Task Parent.png Task Child.PNG
 

Justin

Administrator
Staff member
Did you update the external tree first, before updating the local tree? And the tree loads correctly within the editor? If it loads correctly within the editor it may be best to just delete the task causing the problem and add it back again. There were a lot of serialization changes between 1.5.8 and the current version so it sounds like something is off. You could also try to save it as JSON to see if that gets around it.
 
Top