Add Control to preferred types
(cherry picked from commitec86d32684
) Fix crash by calculating wrong size of array. (cherry picked from commit81b6000812
)
This commit is contained in:
parent
14b8124074
commit
cdb9b51ed1
|
@ -362,17 +362,26 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
||||||
if (!profile_allow_editing) {
|
if (!profile_allow_editing) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
String preferred = "";
|
|
||||||
|
// Prefer nodes that inherit from the current scene root.
|
||||||
Node *current_edited_scene_root = EditorNode::get_singleton()->get_edited_scene();
|
Node *current_edited_scene_root = EditorNode::get_singleton()->get_edited_scene();
|
||||||
|
|
||||||
if (current_edited_scene_root) {
|
if (current_edited_scene_root) {
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Node2D"))
|
for (int i = 0; i < preferred_types.size(); i++) {
|
||||||
preferred = "Node2D";
|
if (ClassDB::is_parent_class(root_class, preferred_types[i])) {
|
||||||
else if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Spatial"))
|
create_dialog->set_preferred_search_result_type(preferred_types[i]);
|
||||||
preferred = "Spatial";
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
create_dialog->set_preferred_search_result_type(preferred);
|
|
||||||
create_dialog->popup_create(true);
|
create_dialog->popup_create(true);
|
||||||
} break;
|
} break;
|
||||||
case TOOL_INSTANCE: {
|
case TOOL_INSTANCE: {
|
||||||
|
|
Loading…
Reference in New Issue