| 1620 | } |
| 1621 | |
| 1622 | void EditorNode::save_resource(const Ref<Resource> &p_resource) { |
| 1623 | // If built-in resource, save the scene instead. |
| 1624 | if (p_resource->is_built_in()) { |
| 1625 | const String scene_path = p_resource->get_path().get_slice("::", 0); |
| 1626 | if (!scene_path.is_empty()) { |
| 1627 | if (ResourceLoader::exists(scene_path) && ResourceLoader::get_resource_type(scene_path) == "PackedScene") { |
| 1628 | save_scene_if_open(scene_path); |
| 1629 | } else { |
| 1630 | // Not a packed scene, so save it as regular resource. |
| 1631 | Ref<Resource> parent_resource = ResourceCache::get_ref(scene_path); |
| 1632 | ERR_FAIL_COND_MSG(parent_resource.is_null(), "Parent resource not loaded, can't save."); |
| 1633 | save_resource(parent_resource); |
| 1634 | } |
| 1635 | return; |
| 1636 | } |
| 1637 | } |
| 1638 | |
| 1639 | // If the resource has been imported, ask the user to use a different path in order to save it. |
| 1640 | String path = p_resource->get_path(); |
| 1641 | if (path.is_resource_file() && !FileAccess::exists(path + ".import")) { |
| 1642 | save_resource_in_path(p_resource, p_resource->get_path()); |
| 1643 | } else { |
| 1644 | save_resource_as(p_resource); |
| 1645 | } |
| 1646 | } |
| 1647 | |
| 1648 | void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path) { |
| 1649 | { |