Open feefladder opened 2 years ago
You would like to automatically create double
and partial_double
scripts for all children (recursively) in a scene?
This might be possible. It would probably have to set the script on all the nodes instead of making new nodes. This will retain any references to the nodes and easily preserve their spot in the tree. Gut does have a replace_node
method (and I think Godot added one awhile back) that will retain names and position in the tree. That could be useful here.
This seems feasible, but might have a lot of issues that I'm not thinking of yet.
You would like to automatically create
double
andpartial_double
scripts for all children (recursively) in a scene?
Exactly, so I can check all signals and everything for integration tests, while not having to build the scene from code :)
This might be possible. It would probably have to set the script on all the nodes instead of making new nodes. This will retain any references to the nodes and easily preserve their spot in the tree. Gut does have a
replace_node
method (and I think Godot added one awhile back) that will retain names and position in the tree. That could be useful here.
I did get it to work at some point with set_script
I could make a proposal PR!
PRs are always welcome!
So this is quite a common use case I think:
I added a script to add functionality to a parent node. Because the parent does quite some initialization and has resources that I'd rather link through the GUI, I want to make a
PackedScene
out of it and load that for my unit (and also integration) tests.However, currently the doubler only doubles the top-level node in a scene. It would be nice to have a
recursive
option (that could default tofalse
) that searches for scripts in all scene nodes and doubles them.I understand it would make things a bit more complex, but since the (partial) double function already does type-checking, maybe adding a boolean would not be too confusing?