You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using an autoload script which itself is relying on named/global (class_name) classes, you will encounter errors during the initial import that looks something like this:
SCRIPT ERROR: Parse Error: Identifier "MyGlobal" not declared in the current scope.
at: GDScript::reload (res://my_autoload.gd:4)
res://my_autoload.gd:4 - Parse Error: Identifier "MyGlobal" not declared in the current scope.
ERROR: Failed to load script "res://my_autoload.gd" with error "Parse error".
at: ResourceFormatLoaderGDScript::load (modules\gdscript\gdscript.cpp:2825)
modules\gdscript\gdscript.cpp:2825 - Failed to load script "res://my_autoload.gd" with error "Parse error". (User)
ERROR: Failed to create an autoload, script 'res://my_autoload.gd' does not inherit from 'Node'.
at: (editor\editor_autoload_settings.cpp:424)
Failed to create an autoload, script 'res://my_autoload.gd' does not inherit from 'Node'.
The problem seems to stem from the fact that the list of global classes (global_script_class_cache.cfg) hasn't been created by the time autoload resources are loaded in the EditorAutoloadSettings constructor, which leads to any such references being undeclared identifiers.
Once this global_script_class_cache.cfg file has been created you won't get errors any longer when loading the project.
Steps to reproduce
Delete any existing .godot folder (if loading the MRP again).
Load the MRP project from command-line.
Note the command-line (stderr) errors as shown in the issue description.
Load the MRP project from command-line again.
Note that there are no errors this time.
Note that these errors might not show up in the editor output log, as EditorLog hasn't been set up by the time they're emitted, so it's important to do this through command-line.
Also note that you can similarly reproduce these errors by running Godot with something like --headless --editor --quit, or even a command-line export, so long as you delete the .godot folder beforehand.
Tested versions
Reproducible in: 4.3.dev [f040a35]
System information
Windows 11 (10.0.22631)
Issue description
When using an autoload script which itself is relying on named/global (
class_name
) classes, you will encounter errors during the initial import that looks something like this:The problem seems to stem from the fact that the list of global classes (
global_script_class_cache.cfg
) hasn't been created by the time autoload resources are loaded in theEditorAutoloadSettings
constructor, which leads to any such references being undeclared identifiers.Once this
global_script_class_cache.cfg
file has been created you won't get errors any longer when loading the project.Steps to reproduce
.godot
folder (if loading the MRP again).stderr
) errors as shown in the issue description.Note that these errors might not show up in the editor output log, as
EditorLog
hasn't been set up by the time they're emitted, so it's important to do this through command-line.Also note that you can similarly reproduce these errors by running Godot with something like
--headless --editor --quit
, or even a command-line export, so long as you delete the.godot
folder beforehand.Minimal reproduction project (MRP)
globals-in-autoloads.zip
The text was updated successfully, but these errors were encountered: