Fix invalid suggested file name when saving resource from a scene that hasn't been saved yet

This commit is contained in:
Artemy Fedotov
2025-09-03 19:20:08 +04:00
parent 0c51ede243
commit 7b850260bf
2 changed files with 5 additions and 2 deletions

View File

@ -4204,7 +4204,7 @@ void SceneTreeDock::attach_shader_to_selected(int p_preferred_mode) {
}
String path = selected_shader_material->get_path();
if (path.is_empty()) {
if (path.get_base_dir().is_empty()) {
String root_path;
if (editor_data->get_edited_scene_root()) {
root_path = editor_data->get_edited_scene_root()->get_scene_file_path();
@ -4215,6 +4215,9 @@ void SceneTreeDock::attach_shader_to_selected(int p_preferred_mode) {
} else {
shader_name = selected_shader_material->get_name();
}
if (shader_name.is_empty()) {
shader_name = "new_shader";
}
if (root_path.is_empty()) {
path = String("res://").path_join(shader_name);
} else {