From 35a9ec140fa6aaa215e2c61e209dac6790d5a0df Mon Sep 17 00:00:00 2001 From: Saulo-de-Souza Date: Wed, 28 Jan 2026 16:05:31 -0300 Subject: [PATCH] CreateDialog: return type name instead of script path for custom types --- editor/gui/create_dialog.cpp | 18 +++++++++++------- editor/gui/create_dialog.h | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/editor/gui/create_dialog.cpp b/editor/gui/create_dialog.cpp index 63261da5ce8..5d422617962 100644 --- a/editor/gui/create_dialog.cpp +++ b/editor/gui/create_dialog.cpp @@ -499,7 +499,7 @@ void CreateDialog::_cleanup() { } void CreateDialog::_confirmed() { - String selected_item = get_selected_type(); + String selected_item = get_selected_type_name(); if (selected_item.is_empty()) { return; } @@ -632,6 +632,14 @@ String CreateDialog::get_selected_type() { return String(selected->get_meta("_script_path", "")); // Script types } +String CreateDialog::get_selected_type_name() { + TreeItem *selected = search_options->get_selected(); + if (!selected) { + return String(); + } + return selected->get_text(0).get_slicec(' ', 0); +} + void CreateDialog::set_base_type(const String &p_base) { base_type = p_base; is_base_type_node = ClassDB::is_parent_class(p_base, "Node"); @@ -669,11 +677,7 @@ Variant CreateDialog::instantiate_selected() { } void CreateDialog::_item_selected() { - String name = get_selected_type(); - if (name.is_resource_file()) { - name = search_options->get_selected()->get_text(0).get_slicec(' ', 0); - } - select_type(name, false); + select_type(get_selected_type_name(), false); } void CreateDialog::_hide_requested() { @@ -690,7 +694,7 @@ void CreateDialog::_favorite_toggled() { return; } - String name = item->get_text(0).get_slicec(' ', 0); + String name = get_selected_type_name(); if (favorite_list.has(name)) { favorite_list.erase(name); diff --git a/editor/gui/create_dialog.h b/editor/gui/create_dialog.h index 22d08fbc646..9e12cd0d5bf 100644 --- a/editor/gui/create_dialog.h +++ b/editor/gui/create_dialog.h @@ -117,6 +117,7 @@ protected: public: Variant instantiate_selected(); String get_selected_type(); + String get_selected_type_name(); void set_base_type(const String &p_base); String get_base_type() const { return base_type; }