Following your exemple, I found this working:
MainScene has a button and a control node (the container for the TemplateScene intances)
TemplateScene has a button and a label
MainScene.gd
extends Node
# the button change the scene inside the container node
onready var switch_scene_button = $Button
onready var container = $Container
onready var template = preload("res://Scenes/TemplateScene.tscn")
# create the scene instances
onready var scene1 = template.instance()
onready var scene2 = template.instance()
# get the button and label of each scene
onready var button1 = scene1.get_node("Button")
onready var button2 = scene2.get_node("Button")
onready var label1 = scene1.get_node("Label")
onready var label2 = scene2.get_node("Label")
# which scene is currently displayed in the container
var current_scene = 1
func _ready():
# connecting signals
switch_scene_button.connect("pressed", self, "switch_scene")
button1.connect("pressed", self, "button1_pressed")
button2.connect("pressed", self, "button2_pressed")
# default values
button1.text = "Active"
container.add_child(scene1)
# remove the current scene in the container and add the next scene
func switch_scene():
for n in container.get_children():
container.remove_child(n)
if current_scene == 1:
current_scene = 2
container.add_child(scene2)
elif current_scene == 2:
current_scene = 1
container.add_child(scene1)
# change the text of the labels
func button1_pressed():
label1.text = "Active"
label2.text = "Inactive"
# change the text of the labels
func button2_pressed():
label2.text = "Active"
label1.text = "Inactive"