diff options
Diffstat (limited to 'editor/script_create_dialog.cpp')
-rw-r--r-- | editor/script_create_dialog.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 7d065b4920..f57dfe4827 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -134,7 +134,7 @@ void ScriptCreateDialog::_notification(int p_what) { path_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); parent_browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); parent_search_button->set_icon(get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); - status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); } break; } } @@ -202,7 +202,7 @@ bool ScriptCreateDialog::_validate_parent(const String &p_string) { } } - return ClassDB::class_exists(p_string) || ScriptServer::is_global_class(p_string); + return EditorNode::get_editor_data().is_type_recognized(p_string); } bool ScriptCreateDialog::_validate_class(const String &p_string) { @@ -372,7 +372,15 @@ void ScriptCreateDialog::_create_new() { const ScriptLanguage::ScriptTemplate sinfo = _get_current_template(); - scr = ScriptServer::get_language(language_menu->get_selected())->make_template(sinfo.content, cname_param, parent_name->get_text()); + String parent_class = parent_name->get_text(); + if (!ClassDB::class_exists(parent_class) && !ScriptServer::is_global_class(parent_class)) { + // If base is a custom type, replace with script path instead. + const EditorData::CustomType *type = EditorNode::get_editor_data().get_custom_type_by_name(parent_class); + ERR_FAIL_NULL(type); + parent_class = "\"" + type->script->get_path() + "\""; + } + + scr = ScriptServer::get_language(language_menu->get_selected())->make_template(sinfo.content, cname_param, parent_class); if (has_named_classes) { String cname = class_name->get_text(); |