Erased my behaviour Trees

hertzrat

New member
edit: I deleted the external tree, and the original tree came back, except the variables were all erased so nothing works. This is still terrifying. I badly need to know how to prevent this from ever happening again

Hi,

Twice now I have been working on a behaviour tree for a long time, once over a day or so. Once after exporting my tree to be an 'external tree', and once randomly, my entire tree emptied out. All I end up with is an error message (at bottom). The export to an external tree came as I made a git commit also, but that should not have affected things

I have lost a large amount of work from this and the trees affected just end up empty. I haven't used a program that had a data loss error like this in years

Is there a fix? What causes this? Can I get my most recently lost tree back?

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 <b3033df3de7e4331a53ff33bc57a3e9d>:0) BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <b3033df3de7e4331a53ff33bc57a3e9d>:0) BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <b3033df3de7e4331a53ff33bc57a3e9d>:0) BehaviorDesigner.Editor.GraphDesigner.Load (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, UnityEngine.Vector2 nodePosition) (at <d917a79751444cb5b4a389f044c18334>:0) BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, System.Boolean inspectorLoad) (at <d917a79751444cb5b4a389f044c18334>:0) BehaviorDesigner.Editor.BehaviorDesignerWindow.ReloadPreviousBehavior () (at <d917a79751444cb5b4a389f044c18334>:0) BehaviorDesigner.Editor.BehaviorDesignerWindow.OnFocus () (at <d917a79751444cb5b4a389f044c18334>: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)
 
Last edited:
If you switch to JSON serialization (top right of the BD editor) you should have much better results. When Unity merges the prefab data it can corrupt the prefab instance state which is why switching to JSON works better.
 
I have not seen this same thing happen with JSON. As always though, make sure you have a backup just in case. Let me know though if you hit any issues with it.
 
Top