Skip to content

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

@jinyangcruise

Description

@jinyangcruise

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions