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.
This commit is contained in:
Hugo Locurcio 2025-03-11 18:12:57 +01:00
parent 2cde9292c3
commit 8171720fe0
2 changed files with 15 additions and 5 deletions

View File

@ -290,6 +290,7 @@ void EditorResourcePicker::_update_menu_items() {
if (paste_valid) { if (paste_valid) {
edit_menu->add_item(TTR("Paste"), OBJ_MENU_PASTE); 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); EditorSettings::get_singleton()->set_resource_clipboard(edited_resource);
} break; } break;
case OBJ_MENU_PASTE: { case OBJ_MENU_PASTE:
case OBJ_MENU_PASTE_AS_UNIQUE: {
edited_resource = EditorSettings::get_singleton()->get_resource_clipboard(); edited_resource = EditorSettings::get_singleton()->get_resource_clipboard();
if (edited_resource->is_built_in() && EditorNode::get_singleton()->get_edited_scene() && if (p_which == OBJ_MENU_PASTE_AS_UNIQUE ||
edited_resource->get_path().get_slice("::", 0) != EditorNode::get_singleton()->get_edited_scene()->get_scene_file_path()) { (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. // Automatically make resource unique if it belongs to another scene,
_edit_menu_cbk(OBJ_MENU_MAKE_UNIQUE); // 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; return;
} }
_resource_changed(); _resource_changed();

View File

@ -75,6 +75,7 @@ class EditorResourcePicker : public HBoxContainer {
OBJ_MENU_SAVE_AS, OBJ_MENU_SAVE_AS,
OBJ_MENU_COPY, OBJ_MENU_COPY,
OBJ_MENU_PASTE, OBJ_MENU_PASTE,
OBJ_MENU_PASTE_AS_UNIQUE,
OBJ_MENU_SHOW_IN_FILE_SYSTEM, OBJ_MENU_SHOW_IN_FILE_SYSTEM,
TYPE_BASE_ID = 100, TYPE_BASE_ID = 100,