MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / save_resource

Method save_resource

editor/editor_node.cpp:1622–1646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1620}
1621
1622void 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
1648void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path) {
1649 {

Callers 9

_resave_scriptsMethod · 0.80
save_current_scriptMethod · 0.80
save_all_scriptsMethod · 0.80
_menu_item_pressedMethod · 0.80
_edit_menu_cbkMethod · 0.80
_file_popup_selectedMethod · 0.80
_save_resourceMethod · 0.80
_copy_fileMethod · 0.80

Calls 6

is_built_inMethod · 0.80
get_sliceMethod · 0.80
is_resource_fileMethod · 0.80
get_pathMethod · 0.45
is_emptyMethod · 0.45
is_nullMethod · 0.45

Tested by 1

_save_resourceMethod · 0.64