Godot Version
v4.3.stable.official [77dcf97d8]
Question
Hi all - thanks in advance! (I’m very new to godot, but not to development.)
I have a script that extends Resource and defines a few basic fields.
I have a scene that has an external script attached to it; in that script, I @export a variable whose type is my custom Resource.
I can use the inspector for the scene to put a new instance of the resource in, and set some of the values; when I run the scene it works as expected.
If I edit the scene’s gdscript and save it, the contents of the resource’s script get dumped into scene file (I opened the .tscn file to see the difference before and after - prior to editing the gdscript the resource is referenced as an ext_resource pointing to the file; after a new sub_resource with type=GDScript is created and the entire contents of the resource script are copied in).
This is causing a problem due to a class_name (since there are now two in the project). I can’t figure out why this is happening though. It only happens when I edit and save the scene’s attached script - it does not happen if I edit the scene in the inspector. To temporarily fix the problem, I can revert the new resource in the inspector, reload the project, and redo the work in the inspector; this works until I edit the scene script again.
As another point of data, I have this same resource being used in other scenes with no problem. This feels like a bug - the editor is doing something strange and dropping all this code in where it shouldn’t be, but I’m not versed enough in the deep details of how everything works to be confident that I’m not doing something wrong.
Any ideas or pointers on how to resolve this?