Tree suddenly empty

Zarathustra

New member
After editing an external tree, suddenly copying Tree-Elements was not possible anymore and after reopening, the tree was empty. Is there any possibility to make it work again? Is it a known Bug?
 
If it helps, i get the following exception. Looks like it stored e second creation of a Shared Variable or something like that.

ArgumentException: An item with the same key has already been added. Key: attackedBranch
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <fb001e01371b4adca20013e0ac763896>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <fb001e01371b4adca20013e0ac763896>:0)
BehaviorDesigner.Runtime.BehaviorSource.UpdateVariablesIndex () (at <21bc8ffd3f9642869b545e48dcf9f1ce>:0)
BehaviorDesigner.Runtime.BehaviorSource.set_Variables (System.Collections.Generic.List`1[T] value) (at <21bc8ffd3f9642869b545e48dcf9f1ce>:0)
BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <21bc8ffd3f9642869b545e48dcf9f1ce>:0)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <21bc8ffd3f9642869b545e48dcf9f1ce>:0)
BehaviorDesigner.Editor.GraphDesigner.Load (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, UnityEngine.Vector2 nodePosition) (at <23cc5cd1c5bf47379f7cfbf30fedcdbf>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior, System.Boolean inspectorLoad) (at <23cc5cd1c5bf47379f7cfbf30fedcdbf>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, System.Boolean loadPrevBehavior) (at <23cc5cd1c5bf47379f7cfbf30fedcdbf>:0)
BehaviorDesigner.Editor.BehaviorDesignerWindow.BehaviorSelectionCallback (System.Object obj) (at <23cc5cd1c5bf47379f7cfbf30fedcdbf>:0)
UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, System.Int32 selected) (at <701f6580abad44cfb237a543dcd0d94b>:0)
 
Are you able to reproduce this error within a fresh project? The only time I have seen an error similar to this is when two SharedVariables classes of the same type were created.
 
Thanks for your fast reply,

I tried, but unfortunately i can not reproduce it. Maybe it happened because i copied a task with a shared variable. I also tried to export it with json serialization and got the following json string:
JSONSerialization:
'{"Variables":[{"Type":"BehaviorDesigner.Runtime.SharedGameObject","Name":"Enemy","IsShared":true,"IsDynamic":true},{"Type":"BehaviorDesigner.Runtime.SharedGameObject","Name":"EnemyGameObject","IsShared":true},{"Type":"BehaviorDesigner.Runtime.SharedGameObject","Name":"DestinationObjectVar","IsShared":true,"GameObjectmValue":0},{"Type":"BehaviorDesigner.Runtime.SharedObject","Name":"PickableVar","IsShared":true},{"Type":"BehaviorDesigner.Runtime.SharedBool","Name":"EdibleVar","IsShared":true,"BooleanmValue":false},{"Type":"BehaviorDesigner.Runtime.SharedGameObject","Name":"CreatureGameObject","IsShared":true},{"Type":"BehaviorDesigner.Runtime.SharedGameObject","Name":"SelfVar","IsShared":true,"GameObjectmValue":1},{"Type":"BehaviorDesigner.Runtime.SharedFloat","Name":"MatingSatisfaction","IsShared":true,"SinglemValue":0},{"Type":"BehaviorDesigner.Runtime.SharedVector3","Name":"DestinationPositionVar","IsShared":true,"Vector3mValue":"(0,0,0)"},{"Type":"BehaviorDesigner.Runtime.SharedBool","Name":"attackedBranch","IsShared":true,"IsDynamic":true,"BooleanmValue":false},{"Type":"BehaviorDesigner.Runtime.SharedBool","Name":"attackedBranch","IsShared":true,"IsDynamic":true,"BooleanmValue":false}]}'

as you can see, there are two "attackedBranch"-Variables. Maybe that caused the problem.
But if i'm right, there is no chance to get the BT back, because the variables are the only thing that got serialized.
Maybe it's possible to catch this error at some point, because it's not that nice to lose a whole behavior tree because of serialization problems.
Luckily my behavior tree was not that big yet.
I also have the feeling, that the shared variable system within the BT doesn't work that well. I often have null values stored in them. Or maybe I'm just doing something wrong there...

But apart from that, nice work and support! :)
 
If you remove one of the duplicated attackedBranch booleans from that JSON serialization then it should clear up the errors. I definitely want to prevent this from happening again though. Let me know if you are able to reproduce the error and I will also see what can be done if there are multiple of the same variable names.
 
Unfortunately, the removal of the duplicated variable cleared the error, but the BT was still empty. For now it did'nt happen again. Maybe just a problem with the binary serialization which i used at first. I hope it doesn't happen again, but if it does, and i definitely know why, I let you know.
 
Top