2024-09-27 16:49:56 -07:00
|
|
|
extends Node
|
|
|
|
|
2024-10-04 10:01:33 -07:00
|
|
|
func get_first_node_of_type(node: Node, type: Variant) -> Node:
|
2024-09-27 16:49:56 -07:00
|
|
|
for child in node.get_children():
|
|
|
|
if is_instance_of(child, type):
|
|
|
|
return child
|
|
|
|
return null
|
|
|
|
|
|
|
|
|
2024-09-30 20:50:05 -07:00
|
|
|
func get_nodes_of_class(node: Node, type: Variant, include_internal: bool = false) -> Array[Variant]:
|
|
|
|
var nodes: Array[Variant] = []
|
|
|
|
for child in node.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
|