Keep property values when extending script

(cherry picked from commit 44cf3c22ac)
This commit is contained in:
Tomasz Chabora
2020-10-25 22:32:32 +01:00
committed by Haoyu Qiu
parent daa4be06b0
commit 4951f50b0f
4 changed files with 69 additions and 13 deletions

View File

@@ -2608,7 +2608,10 @@ void EditorPropertyResource::_resource_selected(const RES &p_resource, bool p_ed
void EditorPropertyResource::_resource_changed(const RES &p_resource) {
// Make visual script the correct type.
Ref<Script> s = p_resource;
bool is_script = false;
if (get_edited_object() && s.is_valid()) {
is_script = true;
EditorNode::get_singleton()->get_inspector_dock()->store_script_properties(get_edited_object());
s->call("set_instance_base_type", get_edited_object()->get_class());
}
@@ -2634,6 +2637,11 @@ void EditorPropertyResource::_resource_changed(const RES &p_resource) {
emit_changed(get_edited_property(), p_resource);
update_property();
if (is_script) {
// Restore properties if script was changed.
EditorNode::get_singleton()->get_inspector_dock()->apply_script_properties(get_edited_object());
}
// Automatically suggest setting up the path for a ViewportTexture.
if (vpt.is_valid() && vpt->get_viewport_path_in_scene().is_empty()) {
if (!scene_tree) {