Error while deserializing the tree on editor window open

I was trying to replicate the behavior tree seen in this video:

While doing so I was adding the WithinRange Task but a bunch of errors were put into the console and the editor window started to go blank. If I now want to open the editor window an error is printed and the tree stays blank.

I did not use any subtrees so the mentioned circular reference is not my problem. This is my error:

Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.GraphDesigner.Editor.Views.GraphView.LoadNode (Opsive.GraphDesigner.Runtime.ILogicNode node, System.Int32 index) (at <e7e4f032c84047298b25368f72de26fd>:0)
Opsive.GraphDesigner.Editor.Views.GraphView.LoadGraph () (at <e7e4f032c84047298b25368f72de26fd>:0)
Opsive.GraphDesigner.Editor.GraphWindow.LoadGraph (Opsive.GraphDesigner.Runtime.IGraph graph, System.Boolean force, System.Boolean updateActive) (at <e7e4f032c84047298b25368f72de26fd>:0)
Opsive.GraphDesigner.Editor.GraphWindow.LoadActiveObject (System.Boolean force) (at <e7e4f032c84047298b25368f72de26fd>:0)
Opsive.GraphDesigner.Editor.GraphWindow.OnEnable () (at <e7e4f032c84047298b25368f72de26fd>:0)
UnityEditor.EditorWindow:GetWindow(Boolean, String)
Opsive.BehaviorDesigner.Editor.BehaviorDesignerWindow:ShowWindow()
Opsive.BehaviorDesigner.Editor.BehaviorDesignerWindow:ShowWindow(IGraph)
Opsive.BehaviorDesigner.Editor.Inspectors.<>c__DisplayClass3_0:<ShowHeaderElements>b__0()
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Code:
Error: Unable to deserialize Behavior Tree (Index 0). This can be caused by recursive subtree references.
UnityEngine.Debug:LogError (object)
Opsive.BehaviorDesigner.Runtime.BehaviorTreeData:DeserializeInternal (Opsive.GraphDesigner.Runtime.IGraph,bool,bool,bool,Opsive.GraphDesigner.Runtime.Variables.SharedVariableOverride[]) (at ./Packages/com.opsive.behaviordesigner/Runtime/BehaviorTreeData.cs:374)
Opsive.BehaviorDesigner.Runtime.BehaviorTreeData:Deserialize (Opsive.GraphDesigner.Runtime.IGraph,bool,bool,bool,Opsive.GraphDesigner.Runtime.Variables.SharedVariableOverride[]) (at ./Packages/com.opsive.behaviordesigner/Runtime/BehaviorTreeData.cs:358)
Opsive.BehaviorDesigner.Runtime.BehaviorTree:Deserialize (bool) (at ./Packages/com.opsive.behaviordesigner/Runtime/BehaviorTree.cs:208)
Opsive.GraphDesigner.Editor.GraphWindow:LoadGraph (Opsive.GraphDesigner.Runtime.IGraph,bool,bool)
Opsive.GraphDesigner.Editor.GraphWindow:LoadActiveObject (bool)
Opsive.GraphDesigner.Editor.GraphWindow:OnFocus ()
UnityEditor.EditorWindow:GetWindow<Opsive.BehaviorDesigner.Editor.BehaviorDesignerWindow> (bool,string)
Opsive.BehaviorDesigner.Editor.BehaviorDesignerWindow:ShowWindow ()
Opsive.BehaviorDesigner.Editor.BehaviorDesignerWindow:ShowWindow (Opsive.GraphDesigner.Runtime.IGraph)
Opsive.BehaviorDesigner.Editor.Inspectors.BehaviorTreeInspector/<>c__DisplayClass3_0:<ShowHeaderElements>b__0 ()
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.BehaviorDesigner.Runtime.BehaviorTreeData.DeserializeInternal (Opsive.GraphDesigner.Runtime.IGraph graph, System.Boolean force, System.Boolean variableForce, System.Boolean injectSubtrees, Opsive.GraphDesigner.Runtime.Variables.SharedVariableOverride[] sharedVariableOverrides) (at ./Packages/com.opsive.behaviordesigner/Runtime/BehaviorTreeData.cs:462)
Opsive.BehaviorDesigner.Runtime.BehaviorTreeData.Deserialize (Opsive.GraphDesigner.Runtime.IGraph graph, System.Boolean force, System.Boolean variableForce, System.Boolean injectSubtrees, Opsive.GraphDesigner.Runtime.Variables.SharedVariableOverride[] sharedVariableOverrides) (at ./Packages/com.opsive.behaviordesigner/Runtime/BehaviorTreeData.cs:358)
Opsive.BehaviorDesigner.Runtime.BehaviorTree.Deserialize (System.Boolean force) (at ./Packages/com.opsive.behaviordesigner/Runtime/BehaviorTree.cs:208)
Opsive.BehaviorDesigner.Editor.Inspectors.VariableUtility.SyncReferenceVariables (Opsive.GraphDesigner.Runtime.IGraph graph) (at <0cb83ee363c54487877a6cfb5c462b0c>:0)
Opsive.BehaviorDesigner.Editor.Inspectors.BehaviorTreeInspector.ShowHeaderElements (UnityEngine.UIElements.VisualElement container) (at <0cb83ee363c54487877a6cfb5c462b0c>:0)
Opsive.Shared.Editor.UIElements.UIElementsInspector.DrawElements (UnityEngine.UIElements.VisualElement container, System.Boolean nested) (at <1e4b410f1e3542e28ea9bddf270eaa24>:0)
Opsive.Shared.Editor.UIElements.UIElementsInspector.CreateInspectorGUI () (at <1e4b410f1e3542e28ea9bddf270eaa24>:0)
UnityEditor.UIElements.InspectorElement.CreateInspectorElementUsingUIToolkit (UnityEditor.Editor targetEditor) (at <8206af52fcad4600bf0422f9f88e9042>:0)
UnityEditor.UIElements.InspectorElement.CreateInspectorElementFromSerializedObject (UnityEditor.SerializedObject bindObject) (at <8206af52fcad4600bf0422f9f88e9042>:0)
UnityEditor.UIElements.InspectorElement.HandleEventBubbleUp (UnityEngine.UIElements.EventBase evt) (at <8206af52fcad4600bf0422f9f88e9042>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventBubbleUpInternal (UnityEngine.UIElements.EventBase evt) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.EventDispatchUtilities.HandleEvent_BubbleUpHandleEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement element, System.Boolean disabled) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.EventDispatchUtilities.HandleEventAtTargetAndDefaultPhase (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement target) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.SendBindingEvent[TEventType] (TEventType evt, UnityEngine.UIElements.VisualElement target) (at <c347caf88b6948589611758b2e6040fd>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindTree (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <c347caf88b6948589611758b2e6040fd>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.ContinueBinding (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <c347caf88b6948589611758b2e6040fd>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.Bind (UnityEngine.UIElements.VisualElement element) (at <c347caf88b6948589611758b2e6040fd>:0)
UnityEditor.UIElements.Bindings.DefaultSerializedObjectBindingImplementation.Bind (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedObject obj) (at <c347caf88b6948589611758b2e6040fd>:0)
UnityEditor.UIElements.BindingExtensions.Bind (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedObject obj) (at <8206af52fcad4600bf0422f9f88e9042>:0)
UnityEditor.UIElements.InspectorElement..ctor (UnityEditor.SerializedObject obj, UnityEditor.Editor editor, UnityEditor.UIElements.InspectorElement+DefaultInspectorFramework defaultInspectorFramework) (at <8206af52fcad4600bf0422f9f88e9042>:0)
UnityEditor.UIElements.InspectorElement..ctor (UnityEditor.Editor editor, UnityEditor.UIElements.InspectorElement+DefaultInspectorFramework defaultInspectorFramework) (at <8206af52fcad4600bf0422f9f88e9042>:0)
UnityEditor.UIElements.InspectorElement..ctor (UnityEditor.Editor editor) (at <8206af52fcad4600bf0422f9f88e9042>:0)
UnityEditor.UIElements.EditorElement.BuildInspectorElement () (at <8206af52fcad4600bf0422f9f88e9042>:0)
UnityEditor.UIElements.EditorElement.CreateInspectorElement () (at <8206af52fcad4600bf0422f9f88e9042>:0)
UnityEditor.EditorElementUpdater.CreateInspectorElementsForMilliseconds (System.Int64 targetMilliseconds) (at <8206af52fcad4600bf0422f9f88e9042>:0)
UnityEditor.PropertyEditor.Update () (at <8206af52fcad4600bf0422f9f88e9042>:0)
UnityEditor.HostView.SendUpdate () (at <8206af52fcad4600bf0422f9f88e9042>:0)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at <8206af52fcad4600bf0422f9f88e9042>:0)

If you need any more information please let me know. I would also like to provide the serialized data but I don't know how to.

Unity 6.0.48f1
Behavior Designer Pro 2.0.10p2
Graph Designer 2.0.9
SensePack 1.0.2

Thanks
 
Using prefab variant creation, I wanted to see if there are some serialize data. I can send you this file if you like to. I also wanted to save this file for future reference because I wanted to go on. So I have created an original prefab out of the variant. This would then contain the whole error data.

What I then discovered was this picture. The graph has been opened again and some tasks are broken now. I guess these are the one that caused the initial serialization errors. Bottom left task should be the WithinRange and the top right pink one should be a SetGameObjectTask to "none". Btw. I did not colored this task.

Aditionally I have had two different trees within the designer. The one on the right was my previous attempt and it was not connected. Now a start task is missing and the trees are connected. Some tasks were also unable to be loaded again like check for boolean equalness. Maybe this will help you a bit.

I will throw away that attempt and make a new one. Those errors are however unmotivating.

Thanks
 

Attachments

  • Screenshot 2025-05-21 121635.png
    Screenshot 2025-05-21 121635.png
    110.4 KB · Views: 6
  • Screenshot 2025-05-21 122045.png
    Screenshot 2025-05-21 122045.png
    141.2 KB · Views: 5
I get this error while trying to export the tree (Wanted to test this because of uploading it here)
Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.BehaviorDesigner.Runtime.BehaviorTreeData.Serialize () (at ./Packages/com.opsive.behaviordesigner/Runtime/BehaviorTreeData.cs:208)
Opsive.BehaviorDesigner.Runtime.Subtree.Clone (Opsive.GraphDesigner.Runtime.IGraph other) (at ./Packages/com.opsive.behaviordesigner/Runtime/Subtree.cs:262)
Opsive.GraphDesigner.Editor.Views.ToolbarView.ExportGraph () (at <e7e4f032c84047298b25368f72de26fd>:0)
Opsive.GraphDesigner.Editor.Views.ToolbarView.<.ctor>b__27_4 () (at <e7e4f032c84047298b25368f72de26fd>:0)
UnityEngine.UIElements.Clickable.Invoke (UnityEngine.UIElements.EventBase evt) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.Clickable.ProcessUpEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.Vector2 localPosition, System.Int32 pointerId) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.Clickable.OnPointerUp (UnityEngine.UIElements.PointerUpEvent evt) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.EventCallbackFunctor`1[TEventType].Invoke (UnityEngine.UIElements.EventBase evt) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.EventCallbackRegistry+DynamicCallbackList.Invoke (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement target) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.EventDispatchUtilities.HandleEvent_BubbleUpCallbacks (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement element) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.EventDispatchUtilities.HandleEventAcrossPropagationPathWithCompatibilityEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.EventBase compatibilityEvt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement target, System.Boolean isCapturingTarget) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement target, System.Boolean isCapturingTarget) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.EventDispatchUtilities.DispatchToCapturingElement (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, System.Int32 pointerId, UnityEngine.Vector2 position) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.EventDispatchUtilities.DispatchToCapturingElementOrElementUnderPointer (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, System.Int32 pointerId, UnityEngine.Vector2 position) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.PointerEventBase`1[T].Dispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <b4f75f0eb2d14004826911645c6175d6>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <a0d49742031a45e5b07072b052aa1408>:0)
 
Can you send the tree that you created to support@opsive.com? I am not sure what is causing this. Based on your last call stack it does look like subtrees are being used.
 
Hi, I just sent the prefab including the serialized tree to the support address (Request 7299). If I recall correctly there may be a subtree reference where I was trying to implement a generic flee behavior. I don't have this subtree any more and I am 100% sure that this does not have any back references to form a cycle. Even after deletion of the subtree the same error occurred.
 
Additionally regarding the subtree: I had two different trees in there. One that was attached to a start node (The one that replicates the video agent behavior) and another tree without a start node that was my previous version. This should just do nothing in my opinion. This second tree had the subreference
 
Hi @Justin, I was able to reproduce the problem. Since you mentioned that you are interested in how the tree got into that state I describe the process of how to reproduce it.

- Create a GameObject prefab and attach it to the scene.
- Add a bunch of components onto the >prefab< (I am using UCC and UIS inkl. integration components plus more custom integration components - Screenshot)
- Open the behavior designer window from the >scene< game object (Not the prefab)
- Add subreferences to a behvaior tree (the more the better I think)
- Add shared game object variables and link them onto some subtree references

Now the performance of the behavior designer window should have degraded when changing something. This degraded performance result in sometimes showing up a "Please Wait" window there Unity/Behavior Designer is doing stuff.

If you don't wait for every action to be completly process and just continue doing your work in the behavior designer editor (Beeing fast is key here) the tree will be broken on some conditions.

I think that there is a race condition occurring when trying to serialize all the data onto the object.

Maybe this will help.
 
Thanks for the followup.

If you don't wait for every action to be completly process and just continue doing your work in the behavior designer editor (Beeing fast is key here) the tree will be broken on some conditions.
With Unity's Please Wait dialog appearing how are you able to continue to work? Doesn't the window prevent you from interacting?
 
Yes it does. But this dialog only appears after Unity noticed that some script is taking more time then expected. Before that I can still do things.
 
Back
Top