[BUG] Unity 2018.3 UCC integration package behavior tree giving errors when exported and added to prefab

Sangemdoko

Moderator
Staff member
Hi

I am using unity 2018.3.0f2 with HDRP

I imported these three assets:
Behavior Designer
Behavior Designer Movement Pack
Third Person Controller

And I downloaded the integration pack from behavior designer for UCC.

1) I opened the demo scene ThirdPerson Melee
2) I opened the behavior tree on agentNolan and I exported the behavior
3) I made a prefab of agentNolan.
4) I added agent Nolan in a scene I made, I baked the navmesh
5) The behavior on Nolan was blank when I opened it, so I added the exported behavior as an external behavior
6) I got plenty of errors both in edit mode and play mode:

Code:
InvalidCastException: Specified cast is not valid.
BinaryDeserialization.BytesToSharedVariable (BehaviorDesigner.Runtime.FieldSerializationData fieldSerializationData, System.Collections.Generic.Dictionary`2[TKey,TValue] fieldIndexMap, System.Byte[] bytes, System.Int32 dataPosition, BehaviorDesigner.Runtime.IVariableSource variableSource, System.Boolean fromField, System.Int32 hashPrefix) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BinaryDeserialization.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.BehaviorDesignerWindow.UpdateTree (System.Boolean firstLoad) (at <6224ec08a63b4190a0704159812b1ad4>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.OnSelectionChange () (at <6224ec08a63b4190a0704159812b1ad4>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <ac823e2bb42b41bda67924a45a0173c3>: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 <ac823e2bb42b41bda67924a45a0173c3>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <ac823e2bb42b41bda67924a45a0173c3>: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)




InvalidCastException: Specified cast is not valid.
BinaryDeserialization.BytesToSharedVariable (BehaviorDesigner.Runtime.FieldSerializationData fieldSerializationData, System.Collections.Generic.Dictionary`2[TKey,TValue] fieldIndexMap, System.Byte[] bytes, System.Int32 dataPosition, BehaviorDesigner.Runtime.IVariableSource variableSource, System.Boolean fromField, System.Int32 hashPrefix) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BinaryDeserialization.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.Runtime.Behavior.CheckForSerialization () (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.BehaviorManager.EnableBehavior (BehaviorDesigner.Runtime.Behavior behavior) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.Behavior.EnableBehavior () (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.Behavior.Start () (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)


InvalidCastException: Specified cast is not valid.
BinaryDeserialization.BytesToSharedVariable (BehaviorDesigner.Runtime.FieldSerializationData fieldSerializationData, System.Collections.Generic.Dictionary`2[TKey,TValue] fieldIndexMap, System.Byte[] bytes, System.Int32 dataPosition, BehaviorDesigner.Runtime.IVariableSource variableSource, System.Boolean fromField, System.Int32 hashPrefix) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BinaryDeserialization.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.Runtime.Behavior.CheckForSerialization () (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.Behavior.DrawTaskGizmos (System.Boolean selected) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.Behavior.OnDrawGizmosSelected () (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

InvalidCastException: Specified cast is not valid.
BinaryDeserialization.BytesToSharedVariable (BehaviorDesigner.Runtime.FieldSerializationData fieldSerializationData, System.Collections.Generic.Dictionary`2[TKey,TValue] fieldIndexMap, System.Byte[] bytes, System.Int32 dataPosition, BehaviorDesigner.Runtime.IVariableSource variableSource, System.Boolean fromField, System.Int32 hashPrefix) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BinaryDeserialization.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.GraphDesigner.Load (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, UnityEngine.Vector2 nodePosition) (at <6224ec08a63b4190a0704159812b1ad4>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, System.Boolean inspectorLoad) (at <6224ec08a63b4190a0704159812b1ad4>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.ReloadPreviousBehavior () (at <6224ec08a63b4190a0704159812b1ad4>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.OnInspectorUpdate () (at <6224ec08a63b4190a0704159812b1ad4>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <ac823e2bb42b41bda67924a45a0173c3>: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 <ac823e2bb42b41bda67924a45a0173c3>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <ac823e2bb42b41bda67924a45a0173c3>: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.OnInspectorUpdate () (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:211)

The behavior gets deleted and I cannot get it to stop.
I'm trying to add the behavior to my own character so that I can start making enemies in my level.

Thank you for your time
 
I'm having the same problem after reopening Unity this morning.
Everything was working properly yesterday.
 
I just tried to reproduce this in 2018.3 but wasn't able to. I may not be reproducing it correctly though:

5) The behavior on Nolan was blank when I opened it, so I added the exported behavior as an external behavior
When you created a prefab of agent nolan it should have brought the behavior tree with it. So this didn't happen?

I'm having the same problem after reopening Unity this morning.
Everything was working properly yesterday.
Are you able to list the steps to reproduce?
 
so the tree was working, then I saved a build, and closed Unity last night. Just this morning I loaded it back up and am getting that error.
The tree was on a nested prefab that was also using UCC. The tree was very similar to the UCC demo tree. Amongst other changes to the tree itself including some reflection, a few of the variables had their values set to the prefab's NavMeshAgent component.

I just tried reimporting Behavior Designer and Movement pack, however, the error remains and the tree hidden.
 
If you are able to reproduce it from a fresh project that would be great. Are you able to revert to a previous commit?
 
the previous commit was before I had completed the behavior tree. I just now exported the most recent version of the tree. I'll try reverting the commit and reimporting the external tree
 
I reverted to a previous commit and its working now. However, I tried reimporting the completed tree and nothing shows up in editor nor variables in inspector. I'm not getting any errors when trying to view completed external tree
 
That makes sense - if the previous tree was corrupted in any way it's not going to be able to load. If you figure out the steps to reproduce that would be great so I can take a closer look at it.
 
damn that issue commit took most of the day... It was working perfectly up until the build

I'll try saving a build with the current tree to see if it corrupts it
 
Can you send me a PM with the tree? I don't want to say that I'll be able to get it back especially since you are using binary serialization but I can at least take a look. I would still like to find a way to reproduce the issue though so I know what went wrong.
 
k thanks, I'll send it in just a minute.
Yeah I wish I could show steps, but since issue took most of the day and wasn't showing any error before building its hard to go through the process. Thanks for all the help so far.
 
I get some error in 2018.3.0f2.

I haven't even tried to set a new prefab. Just trying to use the integration tree (UCC 2) on another scene than the demo (on the demo it works fine).
I can't see the behaviour tree on Alan agent because always is empty and launching the same loop error:
"InvalidCastException: Specified cast is not valid."..........

I have tried 2 different ways, always same error:
1. Adding the external tree to the Behaviour Tree Reference Task
2. Adding the external tree to the Behaviour Tree Component.
I'm using this documentation you sent me here:
https://opsive.com/forum/index.php?threads/duplicate-behavior-tree.525/

I always get either the tree empty or the global variables list empty and same error.

Basically since I bought the BT I haven't been able to use it but in the demo scene (2018.3, I haven't tried on other version)
 
ok... not sure because I haven't test it enough but i think now is solved. The issue it was that once you make a prefab or use the UCC2 tree in the project (not just on the same scene) the scene references fire the errors above....
But how can we use this example tree on another scenes or prefabs?
Exactly with the references to Health, Amno and more importan the waypoints ?
 
Top