diff options
-rw-r--r-- | core/io/resource_format_binary.cpp | 3 | ||||
-rw-r--r-- | core/io/resource_format_xml.cpp | 4 | ||||
-rw-r--r-- | scene/resources/packed_scene.cpp | 10 | ||||
-rw-r--r-- | scene/resources/packed_scene.h | 1 | ||||
-rw-r--r-- | scene/resources/scene_format_text.cpp | 7 | ||||
-rw-r--r-- | tools/editor/editor_data.cpp | 4 | ||||
-rw-r--r-- | tools/editor/editor_node.cpp | 13 |
7 files changed, 37 insertions, 5 deletions
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 796dcde3d0..c008c3f9a4 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -725,7 +725,8 @@ Error ResourceInteractiveLoaderBinary::poll(){ } } else { - path=res_path; + if (!ResourceCache::has(res_path)) + path=res_path; } uint64_t offset = internal_resources[s].offset; diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 74813d24fa..8c8d79948a 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -1570,7 +1570,9 @@ Error ResourceInteractiveLoaderXML::poll() { if (main) { f->close(); resource=res; - resource->set_path(res_path); + if (!ResourceCache::has(res_path)) { + resource->set_path(res_path); + } error=ERR_FILE_EOF; return error; diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index d2795bddb8..03127620f7 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -1597,6 +1597,16 @@ Node *PackedScene::instance(bool p_gen_edit_state) const { return s; } +void PackedScene::replace_state(Ref<SceneState> p_by) { + + state=p_by; + state->set_path(get_path()); +#ifdef TOOLS_ENABLED + state->set_last_modified_time(get_last_modified_time()); +#endif + +} + void PackedScene::recreate_state() { state = Ref<SceneState>( memnew( SceneState )); diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h index 415357b61f..00a812f16a 100644 --- a/scene/resources/packed_scene.h +++ b/scene/resources/packed_scene.h @@ -198,6 +198,7 @@ public: Node *instance(bool p_gen_edit_state=false) const; void recreate_state(); + void replace_state(Ref<SceneState> p_by); virtual void set_path(const String& p_path,bool p_take_over=false); #ifdef TOOLS_ENABLED diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index 2552f682fa..5450b9e2ac 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -302,6 +302,10 @@ Error ResourceInteractiveLoaderText::poll() { if (error) { if (error!=ERR_FILE_EOF) { _printerr(); + } else { + if (!ResourceCache::has(res_path)) { + resource->set_path(res_path); + } } return error; } @@ -403,6 +407,9 @@ Error ResourceInteractiveLoaderText::poll() { _printerr(); } else { resource=packed_scene; + if (!ResourceCache::has(res_path)) { + packed_scene->set_path(res_path); + } } return error; } diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp index d79c1ff466..5e613c658b 100644 --- a/tools/editor/editor_data.cpp +++ b/tools/editor/editor_data.cpp @@ -499,8 +499,8 @@ void EditorData::remove_scene(int p_idx){ bool EditorData::_find_updated_instances(Node* p_root,Node *p_node,Set<String> &checked_paths) { - if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner())) - return false; +// if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner())) +// return false; Ref<SceneState> ss; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 9258637a74..4b965ab9cf 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -3623,7 +3623,18 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo add_io_error(txt); } - sdata->set_path(lpath,true); //take over path + if (ResourceCache::has(lpath)) { + //used from somewhere else? no problem! update state + Ref<PackedScene> ps = Ref<PackedScene>( ResourceCache::get(lpath)->cast_to<PackedScene>() ); + if (ps.is_valid()) { + ps->replace_state( sdata->get_state() ); + ps->set_last_modified_time( sdata->get_last_modified_time() ); + sdata=ps; + } + + } else { + sdata->set_path(lpath,true); //take over path + } Node*new_scene=sdata->instance(true); |