|
@@ -347,7 +347,24 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
|
|
|
node->get_script_instance()->get_property_state(old_state);
|
|
|
}
|
|
|
|
|
|
- node->set(snames[nprops[j].name], props[nprops[j].value], &valid);
|
|
|
+#ifdef TOOLS_ENABLED
|
|
|
+ const Ref<Script> value_as_script = props[nprops[j].value];
|
|
|
+ // It is possible that the user changed an existing script to abstract after it was attached to a node.
|
|
|
+ // When this happens, the user needs to fix it. See https://github.com/godotengine/godot/issues/109171
|
|
|
+ if (value_as_script.is_valid() && value_as_script->is_abstract()) {
|
|
|
+ const String global_class_name = value_as_script->get_global_name();
|
|
|
+ if (global_class_name.is_empty()) {
|
|
|
+ ERR_PRINT("Node \"" + snames[n.name] + "\" previously had a script, but that script is now abstract. Please assign a different script (right-click -> Attach Script...) or change the node to a different type (right-click -> Change Type...) to fix this, then re-save the scene.");
|
|
|
+ } else {
|
|
|
+ ERR_PRINT("Node \"" + snames[n.name] + "\" previously had a class of type \"" + global_class_name + "\", but that class is now abstract. Please assign a different script (right-click -> Attach Script...) or change the node to a different type (right-click -> Change Type...) to fix this, then re-save the scene.");
|
|
|
+ }
|
|
|
+ callable_mp((Object *)node, &Object::remove_meta).call_deferred(SceneStringName(_custom_type_script));
|
|
|
+ } else {
|
|
|
+ node->set_script(props[nprops[j].value]);
|
|
|
+ }
|
|
|
+#else
|
|
|
+ node->set_script(props[nprops[j].value]);
|
|
|
+#endif // TOOLS_ENABLED
|
|
|
|
|
|
//restore old state for new script, if exists
|
|
|
for (const Pair<StringName, Variant> &E : old_state) {
|