Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular dependencies of scenes (by preload) cause a script can not be loaded #70985

Closed
Tracked by #80877
jinyangcruise opened this issue Jan 6, 2023 · 6 comments · Fixed by #93346
Closed
Tracked by #80877

Comments

@jinyangcruise
Copy link

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

  1. open project
  2. open cell.tscn(src/swapPad)in godot and you will find this scene have no script
  3. attach cell.gd to cell.tscn
  4. save and close project
  5. open project again
  6. open cell.tscn(src/swapPad)in godot and you will find this scene still have no script

Minimal reproduction project

test1.zip

@jinyangcruise jinyangcruise changed the title Circular dependencies(by preload) cause a script can not be load Circular dependencies(by preload) cause a script can not be loaded Jan 6, 2023
@Chaosus Chaosus added this to the 4.0 milestone Jan 6, 2023
@Chaosus
Copy link
Member

Chaosus commented Jan 6, 2023

cc @adamscott

@adamscott
Copy link
Member

I confirm this issue. This does not seem to be a regression. I'm investigating.

@adamscott
Copy link
Member

For more info on this issue and why it's currently difficult to fix it, see the comments of my closed PR #71004.

@adamscott adamscott changed the title Circular dependencies(by preload) cause a script can not be loaded Circular dependencies of scenes (by preload) cause a script can not be loaded Jun 13, 2023
@YuriSizov YuriSizov modified the milestones: 4.1, 4.x Jun 26, 2023
@keir
Copy link

keir commented Aug 21, 2023

I put up #80854 to help make the user experience of this engine limitation easier to debug/deal with.

@Muhammad-Fiqri
Copy link

image
I got the same problem.
The scene that get added to the scene with the error script lose its script and unable to be functional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment