25 lines
485 B
GDScript
25 lines
485 B
GDScript
@tool
|
|
|
|
extends Node
|
|
|
|
func find(type):
|
|
var root = null
|
|
if Engine.is_editor_hint():
|
|
root = get_tree().edited_scene_root
|
|
else:
|
|
root = get_tree().root
|
|
|
|
return _find_type_on_base(root, type)
|
|
|
|
func _find_type_on_base(base: Node, type):
|
|
if is_instance_of(base, type):
|
|
return base
|
|
for child in base.get_children():
|
|
var found_node = _find_type_on_base(child, type)
|
|
if found_node != null:
|
|
return found_node
|
|
return null
|
|
|
|
|
|
func is_debug():
|
|
return true |