Exported Resources Lose Default Resource.new() References

Godot Version

4.5.1.stable

Question

Issue description

When exporting a project (release mode), @export variables initialized with Resource.new() lose their references and become null at runtime, even though they work correctly in the editor and debug exports.

This only affects custom Resource subclasses used as default values for exported variables.

Expected behavior

Exported projects should preserve default resource instances created with Resource.new() in exported properties, behaving the same as in debug/editor mode.

Actual behavior

In release exports, the resource instances become null.
This breaks shared or nested resource setups, as subresources are missing at runtime.

Print inside the resource: <Resource#-9223371998233623138>
Print outside the resource:

Export target: Windows Desktop (.exe)

What am I doing wrong?

Solution: (one day later into research and try and error)
Do not initialize (Resource.new()) a resource inside of a resource, otherwise when you export, it will lose it reference. Is it a bug? or am I doing something no allowed?

Post the code.

which part are you interested? Please be a bit more specific, thanks!

All relevant parts. You need to be more specific with your question.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.