Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | figtickler |
I have a script to changes the scene when a button is clicked. Because the scene that holds this script is preloading a scene that preloads the first scene, I get this error:
E 0:00:01.795 load: Resource: 'res://scenes/CityStreet.tscn' is already being loaded. Cyclic reference?
Is there a way to be able to reference scenes to each other without creating a cyclic reference?
The script in question:
extends TextureButton
export var next_scene_path: PackedScene
func _on_pressed():
print("button pressed")
transition()
get_parent().queue_free()
func _get_configuration_warning() -> String:
return "No scene loaded" if not next_scene_path else ""
func transition() -> void:
var next_scene = next_scene_path.instance()
get_tree().get_root().call_deferred("add_child", next_scene)