Browse Source

Merge pull request #107219 from RandomShaper/fix_overduplicate_res

Fix resources wrongly duplicated upon instantiating inherited scenes
Rémi Verschelde 2 months ago
parent
commit
57f064eaba
1 changed files with 6 additions and 6 deletions
  1. 6 6
      scene/resources/packed_scene.cpp

+ 6 - 6
scene/resources/packed_scene.cpp

@@ -356,18 +356,18 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
 					} else {
 						Variant value = props[nprops[j].value];
 
-						// Making sure that instances of inherited scenes don't share the same
-						// reference between them.
-						if (is_inherited_scene) {
-							value = value.duplicate(true);
-						}
-
 						if (value.get_type() == Variant::OBJECT) {
 							//handle resources that are local to scene by duplicating them if needed
 							Ref<Resource> res = value;
 							if (res.is_valid()) {
 								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);
 							}
+						} else {
+							// Making sure that instances of inherited scenes don't share the same
+							// reference between them.
+							if (is_inherited_scene) {
+								value = value.duplicate(true);
+							}
 						}
 
 						if (value.get_type() == Variant::ARRAY) {