Skip to content

Commit

Permalink
Merge pull request #84630 from KoBeWi/what_belongs_to_scene_saves_the…
Browse files Browse the repository at this point in the history
…_scene

Save scene when saving built-in resource
  • Loading branch information
akien-mga committed Nov 13, 2023
2 parents 5945768 + da55c06 commit 80a9f21
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 9 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,15 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St
}

void EditorNode::save_resource(const Ref<Resource> &p_resource) {
// If built-in resource, save the scene instead.
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);
return;
}
}

// If the resource has been imported, ask the user to use a different path in order to save it.
String path = p_resource->get_path();
if (path.is_resource_file() && !FileAccess::exists(path + ".import")) {
Expand Down
10 changes: 1 addition & 9 deletions editor/plugins/script_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2520,15 +2520,7 @@ void ScriptEditor::save_current_script() {
clear_docs_from_script(scr);
}

if (resource->is_built_in()) {
// If built-in script, save the scene instead.
const String scene_path = resource->get_path().get_slice("::", 0);
if (!scene_path.is_empty()) {
EditorNode::get_singleton()->save_scene_if_open(scene_path);
}
} else {
EditorNode::get_singleton()->save_resource(resource);
}
EditorNode::get_singleton()->save_resource(resource);

if (scr.is_valid()) {
update_docs_from_script(scr);
Expand Down

0 comments on commit 80a9f21

Please sign in to comment.