2024-09-27 16:49:56 -07:00
|
|
|
extends Node
|
|
|
|
|
2024-10-05 19:05:53 -07:00
|
|
|
func get_first_node_of_type(parent: Node, type: Variant, include_internal: bool = false) -> Node:
|
|
|
|
var result = null
|
|
|
|
for child in parent.get_children(include_internal):
|
2024-09-27 16:49:56 -07:00
|
|
|
if is_instance_of(child, type):
|
2024-10-05 19:05:53 -07:00
|
|
|
result = child
|
|
|
|
break
|
|
|
|
elif child.get_child_count(include_internal) > 0:
|
|
|
|
result = get_first_node_of_type(child, type, include_internal)
|
|
|
|
if result != null:
|
|
|
|
break
|
|
|
|
return result
|
2024-09-27 16:49:56 -07:00
|
|
|
|
|
|
|
|
2024-10-05 19:05:53 -07:00
|
|
|
func get_nodes_of_class(parent: Node, type: Variant, include_internal: bool = false) -> Array[Variant]:
|
2024-09-30 20:50:05 -07:00
|
|
|
var nodes: Array[Variant] = []
|
2024-10-05 19:05:53 -07:00
|
|
|
for child in parent.get_children(include_internal):
|
2024-09-27 16:49:56 -07:00
|
|
|
if is_instance_of(child, type):
|
|
|
|
nodes.append(child)
|
2024-09-30 20:50:05 -07:00
|
|
|
elif child.get_child_count(include_internal) > 0:
|
|
|
|
nodes.append_array(get_nodes_of_class(child, type, include_internal))
|
2024-09-27 16:49:56 -07:00
|
|
|
return nodes
|