Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reloading scene debug issue #310

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions addons/beehave/debug/global_debugger.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func _on_debug_message(message: String, data: Array) -> bool:
_set_active_tree(data[0])
return true
if message == "visibility_changed":
if _active_tree:
if _active_tree && is_instance_valid(_active_tree):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also had to add this because the previously active tree gets chopped when reloading the scene.

_active_tree._can_send_message = data[0]
return true
return false
Expand All @@ -24,7 +24,7 @@ func _set_active_tree(tree_id: int) -> void:
if not tree:
return

if _active_tree:
if _active_tree && is_instance_valid(_active_tree):
_active_tree._can_send_message = false
_active_tree = tree
_active_tree._can_send_message = true
Expand Down
13 changes: 9 additions & 4 deletions addons/beehave/nodes/beehave_tree.gd
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,15 @@ func _on_scene_tree_node_added_removed(node: Node, is_added: bool) -> void:

if node is BeehaveNode and is_ancestor_of(node):
var sgnal := node.ready if is_added else node.tree_exited
sgnal.connect(
func() -> void: BeehaveDebuggerMessages.register_tree(_get_debugger_data(self)),
CONNECT_ONE_SHOT
)
if is_added:
sgnal.connect(
func() -> void: BeehaveDebuggerMessages.register_tree(_get_debugger_data(self)),
CONNECT_ONE_SHOT
)
else:
sgnal.connect(
func() -> void: BeehaveDebuggerMessages.unregister_tree(get_instance_id())
)


func _physics_process(_delta: float) -> void:
Expand Down
Loading