2019.4 InvalidCastException

FeastSC2

New member
Getting an error that makes the editor window massively lag.
This was after I set an external behaviour in my unit's component.


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 <ddb5579d0d23478c9f73ec2f99600079>:0)
BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BehaviorDesigner.Runtime.BehaviorSource.GetAllVariables () (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, System.Boolean inspectorLoad) (at <4b28e19850d5443cb0dab9a889df4542>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.UpdateTree (System.Boolean firstLoad) (at <4b28e19850d5443cb0dab9a889df4542>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.OnSelectionChange () (at <4b28e19850d5443cb0dab9a889df4542>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>: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 <437ba245d8404784b9fbab9b439ac908>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <af78ad00a40d4f61b82afc6cafb0a416>:0)
UnityEditor.HostView.Invoke (System.String methodName) (at <af78ad00a40d4f61b82afc6cafb0a416>:0)
UnityEditor.HostView.OnSelectionChange () (at <af78ad00a40d4f61b82afc6cafb0a416>:0)

Now I deleted the external behaviour but whenever I am on a prefab with a BehaviourTree component it lags a lot but no errors pop up.

I really loved the idea of this tool but the errors and the lags makes it pretty much unusable. I'll check to see if it's not related to my unity project.
 
Last edited:
Did this just start to happen with 2019.4? Are you able to tell me how to reproduce it or send me a repro scene? Are you able to revert your tree and switch to JSON serialization to see if that helps at all?

It does seem like you are hitting a lot of errors - if you can send me repro scenes/steps to repro it I am happy to see what the cause is!
 
Did this just start to happen with 2019.4?
I didn't have this before 2019.4. But I couldn't say that's the reason for sure.

I reverted to non-serialized data with git and stopped using External Behaviors.

I have been getting messages of "Invalid editor window" lately in my project. I don't know if it's related or not.

I also got messages stating that the variables I had on the behaviour tree weren't being found when I was using the External Behavior.

I'll try and make a repro.

Is there a way to center the view of the behavior window to the nodes? Sometimes I can't find the nodes anymore.
 
More errors of the same kind.
These errors appeared when I deleted a component that the behavior tree's variables relied on.
Now when I open the tree, all the nodes are gone.


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 <ddb5579d0d23478c9f73ec2f99600079>:0)
BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BehaviorDesigner.Editor.GraphDesigner.Load (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, UnityEngine.Vector2 nodePosition) (at <4b28e19850d5443cb0dab9a889df4542>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, System.Boolean inspectorLoad) (at <4b28e19850d5443cb0dab9a889df4542>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.ReloadPreviousBehavior () (at <4b28e19850d5443cb0dab9a889df4542>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.OnProjectWindowChange () (at <4b28e19850d5443cb0dab9a889df4542>:0)
UnityEditor.EditorApplication.Internal_CallProjectHasChanged () (at <af78ad00a40d4f61b82afc6cafb0a416>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

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 <ddb5579d0d23478c9f73ec2f99600079>:0)
BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BehaviorDesigner.Editor.GraphDesigner.Load (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, UnityEngine.Vector2 nodePosition) (at <4b28e19850d5443cb0dab9a889df4542>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, System.Boolean inspectorLoad) (at <4b28e19850d5443cb0dab9a889df4542>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.UpdateTree (System.Boolean firstLoad) (at <4b28e19850d5443cb0dab9a889df4542>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.OnGUI () (at <4b28e19850d5443cb0dab9a889df4542>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>: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 <437ba245d8404784b9fbab9b439ac908>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <af78ad00a40d4f61b82afc6cafb0a416>:0)
UnityEditor.HostView.Invoke (System.String methodName) (at <af78ad00a40d4f61b82afc6cafb0a416>:0)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <af78ad00a40d4f61b82afc6cafb0a416>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <af78ad00a40d4f61b82afc6cafb0a416>:0)
UnityEditor.DockArea.OldOnGUI () (at <af78ad00a40d4f61b82afc6cafb0a416>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <78b213560771414e9fa6f1b95f5ad8bb>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
 
I tried to make that repro but it's just too slow + i'd have to send a big package.

I believe the problem came from having variables that point to positions that no longer exist (it's now not lagging anymore).
 
Top