GodotSharp.SourceGenerators icon indicating copy to clipboard operation
GodotSharp.SourceGenerators copied to clipboard

[OnInstantiate] Unable to instantiate because of wrong resource path

Open Galabar64 opened this issue 1 year ago • 1 comments

When I use [OnInstantiate], the code generated has an error in the resource path. It ends up with just 1 / after the res:

private static PackedScene __Scene__ => __scene__ ??= GD.Load<PackedScene>("res:/customers/Customer.tscn");

Because of that, Godot is unable to find the file:

ERROR: Cannot open file 'res:/customers/Customer.tscn'.
   at: load (scene/resources/resource_format_text.cpp:1367)
ERROR: Failed loading resource: res:/customers/Customer.tscn. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:283)
ERROR: Error loading resource: 'res:/customers/Customer.tscn'.
   at: load (core/core_bind.cpp:74)

For the reproduction, I followed the example in the README.

Godot 4.3.0 net8.0 Linux

Galabar64 avatar Oct 07 '24 19:10 Galabar64

Thanks GB. Away this week, but will address next week. Cheers :)

Cat-Lips avatar Oct 07 '24 23:10 Cat-Lips

Here's the fix. Could you pls test for your use case and if all good I'll merge to main. Cheers :)

GodotSharp.SourceGenerators.2.4.1-241015-1409.Release.zip

Cat-Lips avatar Oct 15 '24 03:10 Cat-Lips

It worked! Thanks a lot and have a nice day ^^

Galabar64 avatar Oct 15 '24 14:10 Galabar64

Uploaded new pre-release nuget package with this fix (241016)

Cat-Lips avatar Oct 17 '24 01:10 Cat-Lips