NodeCanvas Forums › Support › GlobalBlackboard error
Hey,
I got this error when I load a scene with global blackboards not active in scene. Next I load another scene and inspect a task.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
MissingReferenceException: The object of type 'GlobalBlackboard' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. NodeCanvas.Framework.Blackboard.get_name () (at Assets/Plugins/ThirdParty/ParadoxNotion/NodeCanvas/Framework/Runtime/Variables/Blackboard.cs:60) NodeCanvas.Framework.GlobalBlackboard.get_name () (at Assets/Plugins/ThirdParty/ParadoxNotion/NodeCanvas/Framework/Runtime/Variables/GlobalBlackboard.cs:18) NodeCanvas.Editor.TaskEditor.ShowAgentField () (at Assets/Plugins/ThirdParty/ParadoxNotion/NodeCanvas/Framework/Design/PartialEditor/Editors/TaskEditor.cs:339) NodeCanvas.Editor.TaskEditor.ShowInspector (System.Action1 callback, Boolean showTitlebar) (at Assets/Plugins/ThirdParty/ParadoxNotion/NodeCanvas/Framework/Design/PartialEditor/Editors/TaskEditor.cs:195) NodeCanvas.Editor.TaskEditor.ShowTaskInspectorGUI (NodeCanvas.Framework.Task task, System.Action1 callback, Boolean showTitlebar) (at Assets/Plugins/ThirdParty/ParadoxNotion/NodeCanvas/Framework/Design/PartialEditor/Editors/TaskEditor.cs:101) NodeCanvas.Editor.TaskEditor.TaskFieldMulti (NodeCanvas.Framework.Task task, ITaskSystem ownerSystem, System.Type baseType, System.Action1 callback) (at Assets/Plugins/ThirdParty/ParadoxNotion/NodeCanvas/Framework/Design/PartialEditor/Editors/TaskEditor.cs:60) NodeCanvas.Framework.Node.TaskAssignableGUI (NodeCanvas.Framework.Node node) (at Assets/Plugins/ThirdParty/ParadoxNotion/NodeCanvas/Framework/Design/PartialEditor/EDITOR_Node.cs:726) NodeCanvas.Framework.Node.ShowNodeInspectorGUI (NodeCanvas.Framework.Node node) (at Assets/Plugins/ThirdParty/ParadoxNotion/NodeCanvas/Framework/Design/PartialEditor/EDITOR_Node.cs:701) NodeCanvas.Editor.GraphEditor.ShowInspectorGUIPanel (NodeCanvas.Framework.Graph graph, Vector2 canvasMousePos) (at Assets/Plugins/ThirdParty/ParadoxNotion/NodeCanvas/Framework/Design/Editor/Windows/GraphEditor_Panels.cs:71) NodeCanvas.Editor.GraphEditor.ShowPanels (NodeCanvas.Framework.Graph graph, Vector2 canvasMousePos) (at Assets/Plugins/ThirdParty/ParadoxNotion/NodeCanvas/Framework/Design/Editor/Windows/GraphEditor_Panels.cs:22) NodeCanvas.Editor.GraphEditor.OnGUI () (at Assets/Plugins/ThirdParty/ParadoxNotion/NodeCanvas/Framework/Design/Editor/Windows/GraphEditor.cs:544) |
This error occurs because after loading second scene, the list GlobalBlackboard.allGlobals contains null ref. This is due to GlobalBlackboard registration in OnValidate() (called even gameobject is not activated) but is only remove in OnDestroy()(not called when gameobject is not activated).
I found a workaround by checking null when accessing to the GlobalBlackboard.allGlobal list.
I tried to simply explain. Thanks.
Hey,
Thanks for letting me know. I haven’t come across this problem as of yet, but I will try replicate the problem and fix it once I do.
Just out of curiosity, why would you want a Global Blackboard to be deactivated? 🙂
Thanks again.
Join us on Discord: https://discord.gg/97q2Rjh
For streaming level areas, some areas are activated/deactivated according player position but I figure out after this bug that it’s not a good idea because of BlackBoard deserialization which take a lot of GC alloc/CPU time. I have the same issue on SubGraph initalization, do you plan to add an option to “pre-initialize” sub graphs ?
Thanks.
Hey,
“Pre-Initializing” sub-graphs, is indeed something I plan to add. It will probably be an option possible to “tick”, in the GraphOwner inspector 🙂
Let me know what you think.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
I did it with a option in SubTree node (see attachment).
It seems to work well and its a few lines of code:
Add this in SubTree:
[SerializeField]private bool _initOnGraphStart = true;
1 2 3 4 |
public override void OnGraphStarted(){ if (_initOnGraphStart) CheckInstance(); } |
And this in OnNodeInspectorGUI method:
_initOnGraphStart = EditorGUILayout.Toggle("Init On Start", _initOnGraphStart);
Hey,
I see you opted to have the option per-tree, rather than per BehaviourTreeOwner.
That’s a nice approach as well. Do you think that this would be a better option to have it per-tree, rather than a “global” option in the BehaviourTreeOwner itself (thus the root graph) ?
Let me know what you think 🙂
Thanks.
Join us on Discord: https://discord.gg/97q2Rjh