diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index b707f6c3532..288cc2db482 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -238,6 +238,14 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must return ""; } +String ScriptCreateDialog::_get_class_name() const { + if (has_named_classes) { + return class_name->get_text(); + } else { + return ProjectSettings::get_singleton()->localize_path(file_path->get_text()).get_file().get_basename(); + } +} + void ScriptCreateDialog::_class_name_changed(const String &p_name) { if (_validate_class(class_name->get_text())) { is_class_name_valid = true; @@ -287,13 +295,7 @@ void ScriptCreateDialog::ok_pressed() { } void ScriptCreateDialog::_create_new() { - String cname_param; - - if (has_named_classes) { - cname_param = class_name->get_text(); - } else { - cname_param = ProjectSettings::get_singleton()->localize_path(file_path->get_text()).get_file().get_basename(); - } + String cname_param = _get_class_name(); Ref