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
Static variables are not initialized and the static constructor is not called on scripts preloaded by tool scripts.
If the preloaded script has the @tool annotation it is initialized/called.
This only affects scripts run in editor.
Steps to reproduce
When opening the project and then opening the scene node you will see this console output:
_static_init of Node
_ready of Node
Node my_var: 32
OtherClass my_var: <null>
Which indicates that the static variables and the static constructor of the preloaded script is not initialized and run.
If you add @tool to the preloaded script it will work. We have some inconsistency here: in some cases @tool is optional to run dependency code, in other cases it is required (usually Nodes, but in some other cases too, example). I'm not sure if this is a bug as it prevents non-@tool code from being auto-executed.
Godot version
v4.2.dev4.official [549fcce]
System information
Godot v4.2.dev4 - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1080 Ti (NVIDIA; 31.0.15.3667) - AMD Ryzen 9 7900X 12-Core Processor (24 Threads)
Issue description
Static variables are not initialized and the static constructor is not called on scripts preloaded by tool scripts.
If the preloaded script has the
@tool
annotation it is initialized/called.This only affects scripts run in editor.
Steps to reproduce
When opening the project and then opening the scene
node
you will see this console output:Which indicates that the static variables and the static constructor of the preloaded script is not initialized and run.
Minimal reproduction project
static-init.zip
The text was updated successfully, but these errors were encountered: