diff options
Diffstat (limited to 'editor/scene_tree_dock.cpp')
-rw-r--r-- | editor/scene_tree_dock.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 9831f1bd31..41b8baeb2f 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -354,11 +354,15 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { // Prefer nodes that inherit from the current scene root. Node *current_edited_scene_root = EditorNode::get_singleton()->get_edited_scene(); if (current_edited_scene_root) { - static const String preferred_types[] = { "Node2D", "Node3D", "Control" }; - - StringName root_class = current_edited_scene_root->get_class_name(); + String root_class = current_edited_scene_root->get_class_name(); + static Vector<String> preferred_types; + if (preferred_types.empty()) { + preferred_types.push_back("Control"); + preferred_types.push_back("Node2D"); + preferred_types.push_back("Node3D"); + } - for (int i = 0; i < preferred_types->size(); i++) { + for (int i = 0; i < preferred_types.size(); i++) { if (ClassDB::is_parent_class(root_class, preferred_types[i])) { create_dialog->set_preferred_search_result_type(preferred_types[i]); break; @@ -2399,7 +2403,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { } menu->set_size(Size2(1, 1)); - menu->set_position(p_menu_pos); + menu->set_position(get_screen_position() + p_menu_pos); menu->popup(); return; } |