Skip to content

Commit ca98747

Browse files
committed
Make drag-and-dropped resources unique when holding Ctrl/Cmd in the editor
This uses the Make Unique action under the hood (not Make Unique (Recursive), as the dialog fails to spawn just after a drag-and-drop operation).
1 parent 68410ac commit ca98747

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

editor/inspector/editor_resource_picker.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,20 @@ void EditorResourcePicker::_update_menu_items() {
306306
edit_menu->add_icon_item(get_editor_theme_icon(SNAME("Duplicate")), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE);
307307
edit_menu->set_item_disabled(-1, !unique_enabled);
308308

309+
String modifier = "Ctrl";
310+
if (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) {
311+
modifier = "Cmd";
312+
}
313+
const String drag_and_drop_text = vformat(TTRC("Hold %s while drag-and-dropping from the FileSystem dock or another resource picker to automatically make a dropped resource unique."), modifier);
314+
309315
if (!unique_enabled) {
310316
if (EditorNode::get_singleton()->is_resource_internal_to_scene(edited_resource) && EditorNode::get_singleton()->get_resource_count(edited_resource) == 1) {
311-
edit_menu->set_item_tooltip(-1, TTRC("This Resource is already unique."));
317+
edit_menu->set_item_tooltip(-1, String(TTRC("This Resource is already unique.")) + "\n" + drag_and_drop_text);
312318
} else if (_has_parent_resource().is_valid()) {
313-
edit_menu->set_item_tooltip(-1, TTRC("In order to duplicate it, make its parent Resource unique."));
319+
edit_menu->set_item_tooltip(-1, String(TTRC("In order to duplicate it, make its parent Resource unique.")) + "\n" + drag_and_drop_text);
314320
}
321+
} else {
322+
edit_menu->set_item_tooltip(-1, drag_and_drop_text);
315323
}
316324

317325
if (_has_sub_resources(edited_resource)) {
@@ -985,7 +993,14 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_
985993
}
986994

987995
edited_resource = dropped_resource;
988-
_resource_changed();
996+
997+
if (Input::get_singleton()->is_key_pressed(Key::CMD_OR_CTRL)) {
998+
// `_edit_menu_cbk(OBJ_MENU_MAKE_UNIQUE)` already calls `_resource_changed()`,
999+
// so we don't need to manually call it in this case.
1000+
_edit_menu_cbk(OBJ_MENU_MAKE_UNIQUE);
1001+
} else {
1002+
_resource_changed();
1003+
}
9891004
}
9901005
}
9911006

0 commit comments

Comments
 (0)