Default constructor not found for type BehaviorDesigner.Runtime.ExternalBehavior[]

I am trying to override the GetExternalBehaviors() to dynamically decide which external tree to load/unload at runtime. However I get the following error:

MissingMethodException: Default constructor not found for type BehaviorDesigner.Runtime.ExternalBehavior[]
System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) (at <9577ac7a62ef43179789031239ba8798>:0)
System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) (at <9577ac7a62ef43179789031239ba8798>:0)
System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) (at <9577ac7a62ef43179789031239ba8798>:0)
BehaviorDesigner.Runtime.TaskUtility.CreateInstance (System.Type t) (at <58623c9461324266a5b7839460bb9d26>:0)
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) (at <58623c9461324266a5b7839460bb9d26>: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 <58623c9461324266a5b7839460bb9d26>:0)
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) (at <58623c9461324266a5b7839460bb9d26>:0)
BehaviorDesigner.Runtime.JSONDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <58623c9461324266a5b7839460bb9d26>:0)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <58623c9461324266a5b7839460bb9d26>:0)
BehaviorDesigner.Editor.GraphDesigner.Load (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, UnityEngine.Vector2 nodePosition) (at <d4f1a3aa6f1a495496d6efce8625ce9a>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, System.Boolean inspectorLoad) (at <d4f1a3aa6f1a495496d6efce8625ce9a>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.ReloadPreviousBehavior () (at <d4f1a3aa6f1a495496d6efce8625ce9a>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.OnFocus () (at <d4f1a3aa6f1a495496d6efce8625ce9a>:0)
UnityEditor.HostView.OnFocus () (at <c84609c921cb488481d7d8a5fcdf9588>:0)

The only thing I do is add the task to my tree and assign a reference to an external behaviour tree, and it triggers this error and my whole tree dissapears.

Code:

1631713520696.png

I am not sure how to use this tbh since there are no samples so Im just guessing but cant even start testing due to this error.
 
If you create a default constructor for your task it should work:

Code:
public PickProfessionTree() {}
 
If you create a default constructor for your task it should work:

Code:
public PickProfessionTree() {}

That didnt fix it unfortunately. To me it looks like the log is complaining about ExternalBehaviour[].

Do you have code for a task that overrides GetExternalBehaviour I can try?
 
I was able to reproduce what you are seeing. It's because of the List<ExternalBehavior[]> and JSON serialization. If you switch to binary serialization it will work correctly. I will look into why JSON isn't working and send you a new version as soon as I fix it. Thank you for the report.
 
Top