GraphEdit packedScene serialization issue on MenuHbox and connection_lines
Tested versions
-Reproducable on Godot 4.3.stable
System information
Godot v4.3.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1080 Ti (NVIDIA; 32.0.15.6094) - Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz (12 Threads)
Issue description
When using a ResourceSaver to save a scene including a GraphEdit, nodes that you reparent to the menu_box as well as all connection_lines are not saved
Steps to reproduce
-
Create a GraphEdit
var node = Button.new()
node.reparent(get_menu_hbox())
2.b. As for the connection_lines, just create 2 GraphNodes and connect them 4.
self.pack(instance)
ResourceSaver.save(self, "test.tscn")
- open test.tscn in text editor and notice missing button and connection lines
Minimal reproduction project (MRP)
Please upload an MRP to make this easier to test
Please upload an MRP to make this easier to test
added in OP edit: sorry had to update the attachment, forgot to adjust owner of the reparented button
Can confirm the behavior described, but not sure what is expected with the connection lines
CC @Geometror
This is not GraphEdit specific. Setting the owners correctly can be a bit tricky in certain cases. The reason that those nodes are not being saved lies in PackedScene::pack:
(snippet from SceneState::_parse_node)
//discard nodes that do not belong to be processed
if (p_node != p_owner && p_node->get_owner() != p_owner && !p_owner->is_editable_instance(p_node->get_owner())) {
return OK;
}
See #90823 as it's somewhat relativ and contains some useful information (and maybe a workaround, I haven't checked it).
I'd recommend doing you own serialization on top, since that is required anyway for GraphEdit connections by design.
This is not GraphEdit specific. Setting the owners correctly can be a bit tricky in certain cases. The reason that those nodes are not being saved lies in
PackedScene::pack: (snippet fromSceneState::_parse_node)//discard nodes that do not belong to be processed if (p_node != p_owner && p_node->get_owner() != p_owner && !p_owner->is_editable_instance(p_node->get_owner())) { return OK; }See #90823 as it's somewhat relativ and contains some useful information (and maybe a workaround, I haven't checked it).
I'd recommend doing you own serialization on top, since that is required anyway for GraphEdit connections by design.
I'm aware of that other issue. However what is the reasoning of an additional serialisation on top? Why is it the way it is, by design? Kind of seems unintentional and missing to on outside view
Alright, after further investigation I found no clear reason for the current approach, so I went ahead and implemented it in #97449. Still, by handling the serialization manually, you gain the advantage of cleanly separating data from view, which facilitates better modularity and maintainability (depending on your use case of course).