summaryrefslogtreecommitdiff
path: root/editor/plugins/node_3d_editor_plugin.cpp
diff options
context:
space:
mode:
authorfoxydevloper <12120644+foxydevloper@users.noreply.github.com>2021-07-29 07:15:46 -0400
committerfoxydevloper <12120644+foxydevloper@users.noreply.github.com>2021-07-29 15:47:42 -0400
commitf641327dcf541b9ef542983e46892e429fe59334 (patch)
treec91f0202d7feae36332be93a43aaaf50687a29ee /editor/plugins/node_3d_editor_plugin.cpp
parent48857194b360dabdaac7cd4c9c6714546ca15aa1 (diff)
Make drag and drop into viewport add to root node by default
When dragging and dropping a texture, mesh, or scene from the FileSystem into the 2D or 3D viewport, it will be added as a child of the current scene's root node.
Diffstat (limited to 'editor/plugins/node_3d_editor_plugin.cpp')
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index ebd6615ac1..a278b5a37f 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -4066,6 +4066,7 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_
}
bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
+ bool is_ctrl = Input::get_singleton()->is_key_pressed(KEY_CTRL);
selected_files.clear();
Dictionary d = p_data;
@@ -4073,29 +4074,32 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_
selected_files = d["files"];
}
- List<Node *> list = editor->get_editor_selection()->get_selected_node_list();
- if (list.size() == 0) {
- Node *root_node = editor->get_edited_scene();
+ List<Node *> selected_nodes = editor->get_editor_selection()->get_selected_node_list();
+ Node *root_node = editor->get_edited_scene();
+ if (selected_nodes.size() == 1) {
+ Node *selected_node = selected_nodes[0];
+ target_node = root_node;
+ if (is_ctrl) {
+ target_node = selected_node;
+ } else if (is_shift && selected_node != root_node) {
+ target_node = selected_node->get_parent();
+ }
+ } else if (selected_nodes.size() == 0) {
if (root_node) {
- list.push_back(root_node);
+ target_node = root_node;
} else {
- accept->set_text(TTR("No parent to instance a child at."));
+ accept->set_text(TTR("Cannot drag and drop into scene with no root node."));
accept->popup_centered();
_remove_preview();
return;
}
- }
- if (list.size() != 1) {
- accept->set_text(TTR("This operation requires a single selected node."));
+ } else {
+ accept->set_text(TTR("Cannot drag and drop into multiple selected nodes."));
accept->popup_centered();
_remove_preview();
return;
}
- target_node = list[0];
- if (is_shift && target_node != editor->get_edited_scene()) {
- target_node = target_node->get_parent();
- }
drop_pos = p_point;
_perform_drop_data();