Godot Version
4.2.2
Question
I have a scene that has a script that references another script (core.gd). In core.gd, I want to be able to spawn the other scene, so I preload it. Now if I restart the editor, I get a scene missing/corrupted error with no way of fixing it (At least not in Godot. Had to do it with notepad.). I dont understand how I can avoid this in the future because it happened multiple times over multiple Godot versions and multiple projects.
Here are my scripts simplified…
core.gd
extends Node
class_name Core
const RUC_SCENE: PackedScene = preload(
"res://scenes/roller_upgrades_container/roller_upgrades_container.tscn"
)
func switch_to_structure(id: int, is_static_structure: bool) -> void:
var roller_data: Roller = rollers_data[id]
if %BottomContainer.get_child_count() == 0:
var ruc_instance := RUC_SCENE.instantiate() as RollerUpgradesContainer
%BottomContainer.add_child(ruc_instance)
ruc_instance.setup(roller_data)
roller_upgrades_container.gd
extends GridContainer
class_name RollerUpgradesContainer
@onready var core := get_tree().get_first_node_in_group(&"core") as Core
var roller_data: Roller = null
func setup(data: Roller) -> void:
roller_data = data
update_visuals()
Any help is appreciated!