forked from DigitallyTailored/godot-runtime-node-selector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRuntimeSelectorAutoload.gd
More file actions
51 lines (38 loc) · 1.31 KB
/
RuntimeSelectorAutoload.gd
File metadata and controls
51 lines (38 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@tool
extends EditorPlugin
class ExampleEditorDebugger extends EditorDebuggerPlugin:
var found = false
var node_path = ""
func _has_capture(prefix):
return prefix == "clicked_node"
func _capture(message, data, session_id):
if message == "clicked_node:node":
found = false
node_path = str(data[0])
var root_node = EditorInterface.get_edited_scene_root().get_node('/root').find_child("*EditorDebuggerTree*", true, false)
check_editor_trees(root_node)
if !found:
print("Node not found. Please check the remote tab is open")
func check_editor_trees(node : Node, indent_level=0):
if node == null:
return
if node.is_class("Tree"):
var root = node.get_root()
recurse_tree_items(root, "")
for child in node.get_children():
check_editor_trees(child, indent_level + 1)
func recurse_tree_items(item: TreeItem, prefix):
if item == null:
return
if "/" + prefix + item.get_text(0) == node_path: #we found the clicked node!
item.select(0)
found = true
if item.get_children():
for treeItem in item.get_children():
recurse_tree_items(treeItem, prefix + item.get_text(0) + "/")
item = item.get_next()
var debugger = (ExampleEditorDebugger as Variant).new()
func _enter_tree():
add_debugger_plugin(debugger)
func _exit_tree():
remove_debugger_plugin(debugger)