You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue description:
When using Merge From Scene, and then selecting a node in another scene that is an instantiation of a third scene, and then checking Editable Children on the merged node, all children of that node will be duplicated.
Steps to reproduce:
Create a scene, add root Node2D, name it Scene1, add a Sprite node as child. Save as Scene1.tscn.
Create a scene, add root Node2D, name it Scene2, instantiate Scene1.tscn as child. Save as Scene2.tscn.
Create a scene, add root Node2D, name it Scene3.
On root node Scene3, right-click and use Merge From Scene, select Scene2.tscn, select Scene1 node.
On newly merged node, right-click and check Editable Children.
Select the grayed Sprite node move it a little bit.
Save the scene as Scene3.tscn and run it.
The scene in game has 2 sprites displayed.
Close the game and close the Scene3.tscn tab in editor.
Reopen Scene3.tscn again. Now 2 Sprite nodes are visible in editor too, one is grayed and one isn't. When one is selected the other is automatically selected too.
I think I found out what the problem is. EditorSubScene, from which a sub-tree is selected to merge, did not instance the source scene with PackedScene::GEN_EDIT_STATE_INSTANCE, so if the node we are merging is in fact an instanced scene in the source scene, it won't have its data.instance_state set. Later, when Editable Children is checked for the merged node and the scene is saved, SceneState::_parse_node will treat child Sprite of the merged node as not being part of the instanced scene and will write it into the tscn.
So the sprite is duplicated. I changed the scene instantiation call in EditorSubScene::_path_changed to: scene = ps->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
This fixes the problem, but some more feedback would be helpful since I'm new to Godot. I see that @reduz and @akien-mga touched most of this function, so please advise if this is correct solution.
Godot version:
v3.1.1.stable.official
v3.2.dev.custom_build.e71cf83f
OS/device including version:
All
Issue description:
When using Merge From Scene, and then selecting a node in another scene that is an instantiation of a third scene, and then checking Editable Children on the merged node, all children of that node will be duplicated.
Steps to reproduce:
Minimal reproduction project:
MergeInstanceTest.zip
The text was updated successfully, but these errors were encountered: