Invalid cast exception

jolvgames

New member
Hi there,


I´m on 2018.3.0f2, using BD 1.6.1 with 2018.3 sources, Windows 10
I have agent Nolan on the scene with standard integration behavior to UCC.
I get the exception below right off the bat:

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 Assets/Behavior Designer/Runtime/BinaryDeserialization.cs:799)
BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at Assets/Behavior Designer/Runtime/BinaryDeserialization.cs:112)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at Assets/Behavior Designer/Runtime/BehaviorSource.cs:76)
BehaviorDesigner.Runtime.Behavior.CheckForSerialization () (at Assets/Behavior Designer/Runtime/Behavior.cs:307)
BehaviorDesigner.Runtime.Behavior.DrawTaskGizmos (System.Boolean selected) (at Assets/Behavior Designer/Runtime/Behavior.cs:403)
BehaviorDesigner.Runtime.Behavior.OnDrawGizmos () (at Assets/Behavior Designer/Runtime/Behavior.cs:385)
UnityEngine.GUIUtility:processEvent(Int32, IntPtr)


Did not find anything on prev. threads
Anything helps...

J
 
FYI - changing serialization from Binary to JSON in BD Editor does the trick for my models -still unclear what the issue was anyway.
 
I had same error than you. I updated to 2018.3.3 and I had a different error but @Justin sent me a patch and now it works great with 2018.3.3, Prefabs ,the UCC2 integration, external trees, etc...
 
Thank you sir for sharing!
I´m still in an early prototyping phase and I can still manage minor hiccups along the way.
BD and UCC will be the core of the game so it'd better work ;-)!
J
 
This issue related to referencing scene variables from within an external/prefab. This isn't allowed since project-level assets cannot access scene-level assets and Behavior Designer was getting tripped up by the missing reference. Glad you got it working by changing the serialization - this fix will be included in the next version.
 
Top