# GLOBAL.gd attached to AutoLoad
extends Node
var childName
var childSize
var scene1 = preload("res://test_child1.tscn")
var scene2 = preload("res://test_child2.tscn")
var scene3 = preload("res://test_child3.tscn")
# BUILD.gd
extends Control
func _ready():
($currentModule).add_child(GLOBAL.scene1.instance())
GLOBAL.childName = $currentModule.get_child(0).name
#print(GLOBAL.childName)
GLOBAL.childSize = $currentModule.get_node(GLOBAL.childName).get_node("Panel").rect_size / 2
GLOBAL.scene1.instance().position = OS.get_window_size() / 2 - GLOBAL.childSize
# Child scenes .gd named accordingly
extends Node2D
func _ready():
self.position = get_viewport().size / 2 - $Panel.rect_size / 2
func _on_bttn_toScene2_button_up():
get_tree().root.get_node("BUILD/currentModule").add_child(GLOBAL.scene2.instance())
GLOBAL.childName = get_node("..").get_child(1).name
print(GLOBAL.childName)
get_parent().remove_child(self)
queue_free() #Debugger-Monitor showed memory does add up until the idle instance is freed
func _on_bttn_toScene3_button_up():
get_tree().root.get_node("BUILD/currentModule").add_child(GLOBAL.scene3.instance())
GLOBAL.childName = get_node("..").get_child(1).name
print(GLOBAL.childName)
get_parent().remove_child(self)
queue_free()
.