Skip to content

Commit 2ebcde6

Browse files
authored
Fix reloading scene debug issue (#310)
* 🐛 unregister behaviour tree from debugging when removed from scene * Fix tabs being spaces, I hope * Check if active tree is valid before trying to do things with it
1 parent f877108 commit 2ebcde6

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

addons/beehave/debug/global_debugger.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func _on_debug_message(message: String, data: Array) -> bool:
1313
_set_active_tree(data[0])
1414
return true
1515
if message == "visibility_changed":
16-
if _active_tree:
16+
if _active_tree && is_instance_valid(_active_tree):
1717
_active_tree._can_send_message = data[0]
1818
return true
1919
return false
@@ -24,7 +24,7 @@ func _set_active_tree(tree_id: int) -> void:
2424
if not tree:
2525
return
2626

27-
if _active_tree:
27+
if _active_tree && is_instance_valid(_active_tree):
2828
_active_tree._can_send_message = false
2929
_active_tree = tree
3030
_active_tree._can_send_message = true

addons/beehave/nodes/beehave_tree.gd

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,15 @@ func _on_scene_tree_node_added_removed(node: Node, is_added: bool) -> void:
149149

150150
if node is BeehaveNode and is_ancestor_of(node):
151151
var sgnal := node.ready if is_added else node.tree_exited
152-
sgnal.connect(
153-
func() -> void: BeehaveDebuggerMessages.register_tree(_get_debugger_data(self)),
154-
CONNECT_ONE_SHOT
155-
)
152+
if is_added:
153+
sgnal.connect(
154+
func() -> void: BeehaveDebuggerMessages.register_tree(_get_debugger_data(self)),
155+
CONNECT_ONE_SHOT
156+
)
157+
else:
158+
sgnal.connect(
159+
func() -> void: BeehaveDebuggerMessages.unregister_tree(get_instance_id())
160+
)
156161

157162

158163
func _physics_process(_delta: float) -> void:

0 commit comments

Comments
 (0)