diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-23 15:35:44 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-23 15:35:44 +0100 |
commit | 11e227884458e1f5661dcd27e846b6996271467e (patch) | |
tree | 7e62636d0e140bc80774c7b9909d2c13cd4474f4 /scene/resources/packed_scene.cpp | |
parent | 0927e2cffcbff2980a02f52c21d7faf9b3e5ae84 (diff) | |
parent | 4628736894203d4bb94e157ac011495da5bf8713 (diff) | |
download | redot-engine-11e227884458e1f5661dcd27e846b6996271467e.tar.gz |
Merge pull request #57606 from SaracenOne/update_on_reimport
Update instances of scenes which have been reimported.
Diffstat (limited to 'scene/resources/packed_scene.cpp')
-rw-r--r-- | scene/resources/packed_scene.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index c24186a109..e497a628aa 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -1046,6 +1046,25 @@ Ref<SceneState> SceneState::get_base_scene_state() const { return Ref<SceneState>(); } +void SceneState::update_instance_resource(String p_path, Ref<PackedScene> p_packed_scene) { + ERR_FAIL_COND(p_packed_scene.is_null()); + + for (const NodeData &nd : nodes) { + if (nd.instance >= 0) { + if (!(nd.instance & FLAG_INSTANCE_IS_PLACEHOLDER)) { + int instance_id = nd.instance & FLAG_MASK; + Ref<PackedScene> original_packed_scene = variants[instance_id]; + if (original_packed_scene.is_valid()) { + if (original_packed_scene->get_path() == p_path) { + variants.remove_at(instance_id); + variants.insert(instance_id, p_packed_scene); + } + } + } + } + } +} + int SceneState::find_node_by_path(const NodePath &p_node) const { ERR_FAIL_COND_V_MSG(node_path_cache.size() == 0, -1, "This operation requires the node cache to have been built."); |