If you create a Scene in the Editor, you can visually connect to methods in your script. When you open the corresponding .tscn file in a text editor, you can find those saved connections at the end of the file like for example:
Unfortunately, I can’t quite figure out how to do this programatically.
var a = Control.new()
var b = Control.new()
a.add_child(b)
b.focus_entered.connect(a.grab_focus) # Just connect some random
b.owner = a # method for test purposes
var file = PackedScene.new()
file.pack(a)
ResourceSaver.save(file, "res://test.tscn" )
This does not save the connections. I added this little example to bring my point across, but I’ve also tried creating custom classes with custom signals. I can’t @export the signals though, so that doesn’t work either.
Sorry, but if you have the signals connected by code, why do you want to also store them in the scene file? You already have them “stored” in your script.
I don’t see the point in programming the connection of the signals just so that they appear in the scene file. Wouldn’t it be much easier to do it through the editor?
I think I’m missing something.
I’m creating a plugin that can generate code and I wanna save/load whatever the user has created to/from a resource.
It would be useful to save the signals as well. I can also init the connections when the resource is loaded, but Godot seems to be capable of saving the signals. So why not?