diff options
author | Nong Van Tinh <vannongtinh@gmail.com> | 2022-11-28 20:08:05 +0700 |
---|---|---|
committer | Nong Van Tinh <vannongtinh@gmail.com> | 2022-11-28 21:03:00 +0700 |
commit | 6bec9759eb7f71ebf4adfa02f6f6391e6b6870c1 (patch) | |
tree | ffabc1dc823a9d8d423a6b6309603a136cbec3d8 /editor/plugins | |
parent | 690199b7dddd784b435e6ce71365256b29285fe8 (diff) |
Fix incorrect hint when drag-and-drop asset into scene
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 0fe77ec400..cdc933b520 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5504,6 +5504,11 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res)); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); if (texture != nullptr || scene != nullptr) { + bool root_node_selected = EditorNode::get_singleton()->get_editor_selection()->is_selected(EditorNode::get_singleton()->get_edited_scene()); + String desc = TTR("Drag and drop to add as child of current scene's root node.") + "\n" + TTR("Hold Ctrl when dropping to add as child of selected node."); + if (!root_node_selected) { + desc += "\n" + TTR("Hold Shift when dropping to add as sibling of selected node."); + } if (texture != nullptr) { Sprite2D *sprite = memnew(Sprite2D); sprite->set_texture(texture); @@ -5511,14 +5516,15 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons preview_node->add_child(sprite); label->show(); label_desc->show(); - label_desc->set_text(TTR("Drag and drop to add as child of current scene's root node.\nHold Ctrl when dropping to add as child of selected node.\nHold Shift when dropping to add as sibling of selected node.\nHold Alt when dropping to add as a different node type.")); + desc += "\n" + TTR("Hold Alt when dropping to add as a different node type."); + label_desc->set_text(desc); } else { if (scene.is_valid()) { Node *instance = scene->instantiate(); if (instance) { preview_node->add_child(instance); label_desc->show(); - label_desc->set_text(TTR("Drag and drop to add as child of current scene's root node.\nHold Ctrl when dropping to add as child of selected node.\nHold Shift when dropping to add as sibling of selected node.")); + label_desc->set_text(desc); } } } |