godot icon indicating copy to clipboard operation
godot copied to clipboard

Can't preload a scene in AutoLoad script when the scene's script references the AutoLoad

Open lonevox opened this issue 3 years ago • 2 comments

Godot version

4.0.alpha3

System information

Windows 10

Issue description

This appears to be a regression in 4.0, as this works in 3.4.3. Running the scene causes a ParserError crash, when I expect it to run fine.

Steps to reproduce

If you have a simple AutoLoad script like so: image

Which preloads this simple scene with just one script: image

And that script references the AutoLoad script: image

Then running the scene causes a crash: Parser Error: Could not preload resource file "res://Scene.tscn"

Minimal reproduction project

Working project in 3.4.3: AutoloadBugGodot3.4.3.zip

Identical project but in 4.0.alpha3: AutoloadBugGodot4.zip

lonevox avatar Feb 26 '22 09:02 lonevox

I just came here to report this very issue in alpha 6. Glad to see it's already a known issue. Hope to see it resolved soon.

lbowers avatar Apr 26 '22 20:04 lbowers

Just had the same issue in v4.0.alpha13.official [59dcddc45] And maybe this is relevant for fixing this: When running the project from the editor, one can just 'Continue' twice in the debugger and everything seems to work as expected. This can also be seen in the minimal reproduction project above.

In my case I can even confirm that both the reference to the preloaded scene, aswell as the usage of the autoload works afterwards.

Sebastyle avatar Aug 06 '22 13:08 Sebastyle

Still present in the v4 beta, and continuing twice also proceeds past it

zeddyemmy avatar Sep 18 '22 11:09 zeddyemmy

Using load instead of preload does work fine though (at least in 4.0-beta1).

Not sure if there's actually any practical difference between load and preload for a variable in an AutoLoad script, if the loading is done at the top (outside of any function)? Either way it gets loaded immediately, right?

(obviously there's a difference if the preload is to be done inside a function)

freelancer42 avatar Sep 18 '22 13:09 freelancer42