Subtrees are unusable due to glitchy Shared Variables behaviour (Video attached)

Quevanto

New member
Hi! I have been using Behavior Designer's standard version for almost a year. I recently decided to migrate one of my projects from the standard version to the Behavior Designer Pro version. But a certain glitchy behaviour completely halted my migration progress unfortunately.

My game heavily depends on External Behavior Trees, which I learned that are called Subtrees in the Pro version. The problem is, adding and removing shared variables to a subtree is extremely buggy to the extend of being completely unusable. Sometimes variables disappear, sometimes they reappear, sometimes they get deleted completely, and sometimes the UI reserves a slot for a variable but forgets to fill in the slot with the information of the variable. Lots of times it causes information discrepancy between what the Behavior Designer Editor window shows and the inspector window of the gameobject's Behavior Tree component or the Subtree file's inspector window shows.

I attached a screen recording to demonstrate what is happening. Google Drive link: https://drive.google.com/file/d/1HQJoCpUMhqx3wrOAOhYTfFUFV_9DfcEG/view?usp=sharing

This weird behaviour happens whenever I make a change at the codebase. In the video, in order to demonstrate the issue I make changes to the code in the background(on my second monitor) to force Unity to compile script/reload domain. As you can see whenever it happens, UI behaves in unpredictable ways.

Steps to reproduce:
-Create a new Subtree
-Attach the subtree to a gameobject
-Click on the gameobject to make the tree editor show the subtree
-Add variables
-Compile script/reload domain to observe the bugs/glitches
-Repeat adding variables and reload again

Behavior Trees that are not subtrees don't exhibit this issue and function normally.

Other useful information:
-Unity 6000.0.38f1
-Uninstalled standard Behavior Designer completely from the project before importing Behavior Designer Pro
-Asset Version: 2.0.14p1
-Windows 11
-I normally use Hot Reload, but I disabled it in the video.
-Was able to reproduce the issue in a freshly created new project

Anyone have any recommendations on this issue? I love Behavior Designer, and really want to migrate to the Pro version. But unfortunately I will have to revert back to the standard version if I wouldn't be able to solve this issue. Unfortunately as the project goes on and codebase gets bigger, It will become even harder to transition to the Pro version in the future. So I hope I will be able to fix it soon.
 
I don't know if related, but I also realised that this error below pops up sometimes when I drag and drop a subtree from the project window into a gameobject's Behavior Tree component's Subtree slot. This happens only the first time I assign a subtree to a Behavior Tree component. After that, assigning does not cause the error again. If I assign a different subtree, then error logs again. But each subtree can cause the log to happen only once. The error also sometimes happens when I set the Subtree slot to none(although I couldn't understand the pattern to reproduce it when setting it to none).


NullReferenceException: Object reference not set to an instance of an object
Opsive.GraphDesigner.Editor.Elements.SharedVariablesElement.IsSubgraphContainer (Opsive.GraphDesigner.Runtime.Variables.ISharedVariableContainer container) (at <bf6ddbd052fc48519cf69fc75cc600cd>:0)
Opsive.GraphDesigner.Editor.Elements.SharedVariablesElement.OnContainerChanged (Opsive.GraphDesigner.Editor.Elements.SharedVariablesElement element, Opsive.GraphDesigner.Runtime.Variables.ISharedVariableContainer container) (at <bf6ddbd052fc48519cf69fc75cc600cd>:0)
Opsive.GraphDesigner.Editor.Events.GraphEventHandler.Invoke[T1,T2] (Opsive.GraphDesigner.Editor.Events.GraphEventType eventType, T1 arg1, T2 arg2) (at <bf6ddbd052fc48519cf69fc75cc600cd>:0)
Opsive.BehaviorDesigner.Editor.Inspectors.BehaviorTreeInspector+<>c__DisplayClass3_0.<ShowHeaderElements>b__1 (System.Object obj) (at <9e09767db5dd453eb92af374ba78c507>:0)
Opsive.Shared.Editor.UIElements.FieldInspectorView+<>c__DisplayClass8_0.<AddField>b__0 (System.Object value) (at <623d9cb1c1c7404e8c15ebe2c9efa691>:0)
Opsive.Shared.Editor.UIElements.FieldInspectorView+<>c__DisplayClass10_0.<AddField>b__1 (System.Object changedValue) (at <623d9cb1c1c7404e8c15ebe2c9efa691>:0)
Opsive.Shared.Editor.UIElements.Controls.Types.UnityObjectControl+<>c__DisplayClass2_0.<GetControl>b__0 (UnityEngine.UIElements.ChangeEvent`1[T] c) (at <623d9cb1c1c7404e8c15ebe2c9efa691>:0)
UnityEngine.UIElements.EventCallbackFunctor`1[TEventType].Invoke (UnityEngine.UIElements.EventBase evt) (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.EventCallbackRegistry+DynamicCallbackList.Invoke (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement target) (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.EventDispatchUtilities.HandleEventAcrossPropagationPath (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.VisualElement target, System.Boolean isCapturingTarget) (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.EventDispatchUtilities.DefaultDispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.EventBase.Dispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <f1c909cad80d4b24ac89c1095fc1f01b>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <1b026406e9c7449283af5e3e7bcf93f9>:0)
 
Thanks for the repro. The editor does some synchronization between the behavior tree component and the ScriptableObject subtree. It looks like this synchronization is causing some problems. I will get this fixed this week, but in the meantime if you instead add the variable to your subtree ScriptableObject it will persist correctly.
 
Back
Top