diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 2cee2c2198b0..dc902564906c 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1285,7 +1285,14 @@ void EditorNode::save_resource(const Ref &p_resource) { if (p_resource->is_built_in()) { const String scene_path = p_resource->get_path().get_slice("::", 0); if (!scene_path.is_empty()) { - save_scene_if_open(scene_path); + if (ResourceLoader::exists(scene_path) && ResourceLoader::get_resource_type(scene_path) == "PackedScene") { + save_scene_if_open(scene_path); + } else { + // Not a packed scene, so save it as regular resource. + Ref parent_resource = ResourceCache::get_ref(scene_path); + ERR_FAIL_COND_MSG(parent_resource.is_null(), "Parent resource not loaded, can't save."); + save_resource(parent_resource); + } return; } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 5ff8cd17eaf7..e986510895dd 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1001,6 +1001,11 @@ void ScriptEditor::_res_saved_callback(const Ref &p_res) { } } + if (p_res.is_valid()) { + // In case the Resource has built-in scripts. + _mark_built_in_scripts_as_saved(p_res->get_path()); + } + _update_script_names(); Ref