Browse Source

-force exporting of original script exported variables on overriden scripts
-this works around the problem of scripts being reloaded and their properties lost
-fixes #2958

Juan Linietsky 9 years ago
parent
commit
101049518a
1 changed files with 13 additions and 0 deletions
  1. 13 0
      scene/resources/packed_scene.cpp

+ 13 - 0
scene/resources/packed_scene.cpp

@@ -509,6 +509,19 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
 				}
 			}
 
+			if (exists && p_node->get_script_instance()) {
+				//if this is an overriden value by another script, save it anyway
+				//as the script change will erase it
+				//https://github.com/godotengine/godot/issues/2958
+
+				bool valid=false;
+				p_node->get_script_instance()->get_property_type(name,&valid);
+				if (valid) {
+					exists=false;
+					isdefault=false;
+				}
+			}
+
 
 			if (exists && bool(Variant::evaluate(Variant::OP_EQUAL,value,original))) {
 				//exists and did not change