Skip to content

Commit 57f064e

Browse files
committed
Merge pull request #107219 from RandomShaper/fix_overduplicate_res
Fix resources wrongly duplicated upon instantiating inherited scenes
2 parents a663949 + c854462 commit 57f064e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

scene/resources/packed_scene.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,18 +356,18 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
356356
} else {
357357
Variant value = props[nprops[j].value];
358358

359-
// Making sure that instances of inherited scenes don't share the same
360-
// reference between them.
361-
if (is_inherited_scene) {
362-
value = value.duplicate(true);
363-
}
364-
365359
if (value.get_type() == Variant::OBJECT) {
366360
//handle resources that are local to scene by duplicating them if needed
367361
Ref<Resource> res = value;
368362
if (res.is_valid()) {
369363
value = make_local_resource(value, n, resources_local_to_sub_scene, node, snames[nprops[j].name], resources_local_to_scene, i, ret_nodes, p_edit_state);
370364
}
365+
} else {
366+
// Making sure that instances of inherited scenes don't share the same
367+
// reference between them.
368+
if (is_inherited_scene) {
369+
value = value.duplicate(true);
370+
}
371371
}
372372

373373
if (value.get_type() == Variant::ARRAY) {

0 commit comments

Comments
 (0)