From 8171720fe02094e7388c40264495e856fdee9a3f Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Tue, 11 Mar 2025 18:12:57 +0100 Subject: [PATCH] Add Paste as Unique option to the editor resource picker dropdown This is equivalent to using Paste, then immediately using Make Unique afterwards. This saves time when pasting a resource that you know will need to be unique. --- editor/editor_resource_picker.cpp | 19 ++++++++++++++----- editor/editor_resource_picker.h | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 70d00b2df8..86bfab0b6d 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -290,6 +290,7 @@ void EditorResourcePicker::_update_menu_items() { if (paste_valid) { edit_menu->add_item(TTR("Paste"), OBJ_MENU_PASTE); + edit_menu->add_item(TTRC("Paste as Unique"), OBJ_MENU_PASTE_AS_UNIQUE); } } @@ -439,12 +440,20 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { EditorSettings::get_singleton()->set_resource_clipboard(edited_resource); } break; - case OBJ_MENU_PASTE: { + case OBJ_MENU_PASTE: + case OBJ_MENU_PASTE_AS_UNIQUE: { edited_resource = EditorSettings::get_singleton()->get_resource_clipboard(); - if (edited_resource->is_built_in() && EditorNode::get_singleton()->get_edited_scene() && - edited_resource->get_path().get_slice("::", 0) != EditorNode::get_singleton()->get_edited_scene()->get_scene_file_path()) { - // Automatically make resource unique if it belongs to another scene. - _edit_menu_cbk(OBJ_MENU_MAKE_UNIQUE); + if (p_which == OBJ_MENU_PASTE_AS_UNIQUE || + (EditorNode::get_singleton()->get_edited_scene() && edited_resource->is_built_in() && edited_resource->get_path().get_slice("::", 0) != EditorNode::get_singleton()->get_edited_scene()->get_scene_file_path())) { + // Automatically make resource unique if it belongs to another scene, + // or if requested by the user with the Paste as Unique option. + if (p_which == OBJ_MENU_PASTE_AS_UNIQUE) { + // Use the recursive version when using Paste as Unique. + // This will show up a dialog to select which resources to make unique. + _edit_menu_cbk(OBJ_MENU_MAKE_UNIQUE_RECURSIVE); + } else { + _edit_menu_cbk(OBJ_MENU_MAKE_UNIQUE); + } return; } _resource_changed(); diff --git a/editor/editor_resource_picker.h b/editor/editor_resource_picker.h index 29c30f7164..856d04503c 100644 --- a/editor/editor_resource_picker.h +++ b/editor/editor_resource_picker.h @@ -75,6 +75,7 @@ class EditorResourcePicker : public HBoxContainer { OBJ_MENU_SAVE_AS, OBJ_MENU_COPY, OBJ_MENU_PASTE, + OBJ_MENU_PASTE_AS_UNIQUE, OBJ_MENU_SHOW_IN_FILE_SYSTEM, TYPE_BASE_ID = 100,