From e65e69f14d94716bb95a9ae0f9a5ce6107b0af86 Mon Sep 17 00:00:00 2001 From: Variable <77773850+Variable-ind@users.noreply.github.com> Date: Wed, 10 May 2023 15:45:38 +0500 Subject: [PATCH] Make cloned 3D cel have the same selected object as the orignal (#855) * Update 3DShapeEdit.gd do not set selected to null * clone cel recieves selected cel from it's parent * Add one more yield --- src/Tools/3DShapeEdit.gd | 6 ++++++ src/UI/Timeline/AnimationTimeline.gd | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/Tools/3DShapeEdit.gd b/src/Tools/3DShapeEdit.gd index 25075b37b..b5ec213d8 100644 --- a/src/Tools/3DShapeEdit.gd +++ b/src/Tools/3DShapeEdit.gd @@ -205,6 +205,7 @@ func _cel_changed() -> void: return get_child(0).visible = true _cel = Global.current_project.get_current_cel() + var selected = _cel.selected _cel.selected = null if not _cel.is_connected("scene_property_changed", self, "_set_cel_node_values"): _cel.connect("scene_property_changed", self, "_set_cel_node_values") @@ -215,6 +216,11 @@ func _cel_changed() -> void: _set_cel_node_values() _fill_object_option_button() + # two yields are required + yield(get_tree(), "idle_frame") + yield(get_tree(), "idle_frame") + _cel.selected = selected + func _new_object_popup_id_pressed(id: int) -> void: if id == Cel3DObject.Type.IMPORTED: diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index 8b227ef52..3ffa54b62 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -276,10 +276,14 @@ func copy_frames(indices := []) -> void: for l in range(project.layers.size()): var src_cel: BaseCel = project.frames[f].cels[l] # Cel we're copying from, the source var new_cel: BaseCel + var selected_id := 0 if src_cel is Cel3D: new_cel = src_cel.get_script().new( src_cel.size, false, src_cel.object_properties, src_cel.scene_properties ) + if src_cel.selected != null: + selected_id = src_cel.selected.id + else: new_cel = src_cel.get_script().new() if project.layers[l].new_cels_linked: @@ -294,6 +298,9 @@ func copy_frames(indices := []) -> void: else: new_cel.set_content(src_cel.copy_content()) new_cel.opacity = src_cel.opacity + if new_cel is Cel3D: + if selected_id in new_cel.object_properties.keys(): + new_cel.selected = new_cel.get_object_from_id(selected_id) new_frame.cels.append(new_cel) # Loop through the tags to see if the frame is in one