@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_parent_type(node: Node, type: Script): var current_node = node if node == null: return null #print("Searching for " + type.get_global_name() + " from " + node.name) var i = 0 while current_node != null and i < 10: i += 1 if is_instance_of(current_node, type): return current_node current_node = current_node.get_parent() return null; 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 center_rect(rect: Rect2) -> Rect2: return Rect2(rect.size / -2, rect.size) func is_debug(): return true