-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save branch as scene saves children without owner set #82756
Comments
#61966 attempted to fix a similar issue. The question is whether we want to handle unowned nodes in the editor (like it was before #45937) or it's fine to have an exception, as saving branch as scene is not the same as using |
Hi. I will always be in favor of consistency and predictability, mostly in terms of UI/UX (i.e. workflow), not only consistency of You can also think about this that way: saving branch as a scene in fact destroys original subtree when you have some unowned childs. You're getting a modified (freezed?) copy, with all ghosts visible. This is not expected, because you, as the person using the editor, never created / touched these nodes in orginal subtree. |
I was going to suggest using internal children, but they seem bugged for whatever reason. If you add internal child from script, it still has the issue you described. I wonder how nodes with internal children (like ScrollContainer) are not affected. |
Hmm, I'll check this again. I haven't tried adding tool nodes as internal. Regardless, please bear in mind that subtree can be unexpectedly modified by adding unowned nodes when saving branch as a scene, i.e. the workflow "local node <-> saved branch" is not reversible anymore. This can affect other use cases. If someone really wants to save all nodes, including ghosts/unowned, I would suggest adding an "Include unowned children" checkbox somewhere, disabled by default. Disabled, because most users wants to save what they see (-> WYSIWYG).
So data loss in editable nodes was solved by changing the structure of a subtree? Or maybe it wasn't intended? |
I don't think it was intended. The regression was fixed afterwards, but the fixed behavior was still different. |
Thanks. I'm attaching the patch I'm currently testing. Maybe you or someone else would like to check it against regressions. It just reverts 0559fc5, so I'm not too happy with that. But most important for now is to fix the regression. |
Reverting that will most likely re-introduce #42611, so it's not acceptable. |
Right. I've converted MRP for #42611 and reproduced the issue. |
It seems that the original node can be referenced to save the branch, because the nodes visible in the scene tree are all nodes with an owner. What we want to save are these visible nodes. And their owners should have the same owner as the new scene root. godot/editor/gui/scene_tree_editor.cpp Lines 200 to 209 in 51f81e1
|
Godot currently saves not only visible nodes in scene tree. It saves unvisible / unowned, too (i.e. added by editor tools). This is unexpected. |
The solution is to take advantage of the fact that they are not visible in the scene dock and exclude them. godot/editor/scene_tree_dock.cpp Line 2675 in 51f81e1
The child nodes in |
Yes. And you can do that by checking ownership of the original node (before duplication). They're not a subscenes yet, and the logic of saving a branch is not using EDIT: |
Godot version
4.2.dev [44e399e]
System information
Linux
Issue description
I have node with a
@tool
script. The script adds child nodes needed only for the editor.I'm saving the branch of
CustomNode
as a new scene, and the CSGBox saves too, which is unexpected behaviour:The manual says clearly, that nodes without owners will not be saved to the PackedScene:
Unfortunately "Save Branch as Scene" changes ownership of all nodes. Tool script has no possibility to prevent that.
The process of "Saving Branch as Scene" and reverting it by "Make Local" isn't reversible now - it adds next child nodes each time.
Steps to reproduce
Minimal reproduction project
save_branch_bug.zip
save_branch_bug.tscn
if it is not opened alreadyCustomNode
and select "Save branch as a new scene"You will see CSGBox in a nodes tree. Expected result: no CSGBox node visible in the tree. To make sure: click on the
_CSGBox3D_<number>
node and change it's position. You will notice two boxes. Should be just one.Possible fix
The patch I pasted here previously was wrong - it was causing data loss
The old
Node::duplicate_and_reown
contained conditional owner setting (not sure whatp_reown_map
was, but ifowner
wasNULL
the new owner was not set):The issue was probably introduced in 0559fc5.
EDIT: I've reverted 0559fc5 with small changes to match HEAD. The old code was working as expected. There is no saved nodes without owner, there is no duplicated boxes, and other children with owner set are saved. So this is the confirmation that 0559fc5 introduced this bug.
Please revert itCan't be reverted.The text was updated successfully, but these errors were encountered: