-
-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Circular dependencies of scenes (by preload) cause a script can not be loaded #70985
Description
Godot version
v4.0.beta10.official [d0398f6]
System information
Vulkan API 1.3.205 - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce RTX 3060 Ti
Issue description
My project contains two scenes "cell.tscn"(attached with a script "cell.gd") and "swap_pad.tscn" (attached with a script "swap_pad.gd"). Everytime I open this project, the "cell.tscn" always lose its script "cell.gd" with an error log :
ERROR: res://src/swapPad/cell.tscn:9 - Parse Error: [ext_resource] referenced non-loaded resource at: res://src/swapPad/cell.gd
at: _parse_ext_resource (scene/resources/resource_format_text.cpp:178)
I need to re-attach this script to the scene to fix it temporarily but next time this problem happen again.
I finally figured out this problem happens if two scripts have circular dependencies. I don't know if this problem is or not a bug of Godot. If not, why can I fix it temporarily by re-attach the script to the scene.
Content of "cell.gd":
extends CenterContainer
var _swapPad : SwapPad = null
Content of "swap_pad.gd"
extends Control
class_name SwapPad
func _ready():
var cellClass := preload("res://src/swapPad/cell.tscn")
Steps to reproduce
0.download minimal reproduction project below
- open project
- open cell.tscn(src/swapPad)in godot and you will find this scene have no script
- attach cell.gd to cell.tscn
- save and close project
- open project again
- open cell.tscn(src/swapPad)in godot and you will find this scene still have no script