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

preload cause ' cyclic resource inclusion' error #77436

Closed
Tracked by #80877
SmallKi opened this issue May 24, 2023 · 3 comments
Closed
Tracked by #80877

preload cause ' cyclic resource inclusion' error #77436

SmallKi opened this issue May 24, 2023 · 3 comments
Labels

Comments

@SmallKi
Copy link

SmallKi commented May 24, 2023

Godot version

4.0.3.stable

System information

Windows11, GLES3

Issue description

I has a root scene contains a scene2 in the node tree, and if now I use preload() function in other .gd files, will cause ' possible cyclic resource inclusion' error.

Steps to reproduce

if you use my reproduction project directly:
(on start, output will get a error, scene1.gd will auto disattach from scene1.tscn)

  1. attach scene1.gd on scene1.tscn
  2. run the scene2, will show errors in output

start from a new project:

  1. create two scenes: scene1.tscn, a scene2.tscn
  2. scene2.tscn instantiates a child from scene1.tsn
  3. scene1.tscn add a script, add write:
extends Node2D
class_name Scene1

const scene1 := preload("res://Scene1.tscn")

func Create() -> Scene1:
	# scene1 will be null
	return scene1.instantiate() as Scene1
  1. run the scene2 or restart the editor, will show errors

Minimal reproduction project

CyclicResource.zip

@Calinou
Copy link
Member

Calinou commented May 24, 2023

Use load() instead of preload(), as cyclic references are not supported with preload().

@AThousandShips
Copy link
Member

cyclic references are not supported with preload().

Should probably be documented

@KoBeWi
Copy link
Member

KoBeWi commented May 28, 2023

Duplicate of #77090

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants