25 lines
654 B
GDScript
25 lines
654 B
GDScript
@tool
|
|
extends EditorScenePostImport
|
|
|
|
|
|
func _post_import(scene: Node) -> Object:
|
|
if scene.get_child_count(true) != 1:
|
|
push_error("Ruh oh! 342808")
|
|
return null
|
|
var new_root: Node = scene.get_child(0)
|
|
var billiard: Node = preload("billiard.tscn").instantiate()
|
|
billiard.name = scene.name
|
|
take_children(new_root, billiard)
|
|
take_ownership(billiard, billiard)
|
|
return billiard
|
|
|
|
func take_children(src: Node, dest: Node):
|
|
for child in src.get_children(true):
|
|
src.remove_child(child)
|
|
dest.add_child(child)
|
|
|
|
func take_ownership(node: Node, owner: Node):
|
|
for child in node.get_children(true):
|
|
child.owner = owner
|
|
take_ownership(child, owner)
|