Keep property values when extending script
This commit is contained in:
parent
8b454f8b41
commit
44cf3c22ac
4 changed files with 71 additions and 9 deletions
|
|
@ -453,6 +453,9 @@ void InspectorDock::_bind_methods() {
|
|||
|
||||
ClassDB::bind_method("edit_resource", &InspectorDock::edit_resource);
|
||||
|
||||
ClassDB::bind_method("store_script_properties", &InspectorDock::store_script_properties);
|
||||
ClassDB::bind_method("apply_script_properties", &InspectorDock::apply_script_properties);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("request_help"));
|
||||
}
|
||||
|
||||
|
|
@ -565,6 +568,31 @@ EditorPropertyNameProcessor::Style InspectorDock::get_property_name_style() cons
|
|||
return property_name_style;
|
||||
}
|
||||
|
||||
void InspectorDock::store_script_properties(Object *p_object) {
|
||||
ERR_FAIL_NULL(p_object);
|
||||
ScriptInstance *si = p_object->get_script_instance();
|
||||
if (!si) {
|
||||
return;
|
||||
}
|
||||
si->get_property_state(stored_properties);
|
||||
}
|
||||
|
||||
void InspectorDock::apply_script_properties(Object *p_object) {
|
||||
ERR_FAIL_NULL(p_object);
|
||||
ScriptInstance *si = p_object->get_script_instance();
|
||||
if (!si) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const Pair<StringName, Variant> &E : stored_properties) {
|
||||
Variant current;
|
||||
if (si->get(E.first, current) && current.get_type() == E.second.get_type()) {
|
||||
si->set(E.first, E.second);
|
||||
}
|
||||
}
|
||||
stored_properties.clear();
|
||||
}
|
||||
|
||||
InspectorDock::InspectorDock(EditorData &p_editor_data) {
|
||||
singleton = this;
|
||||
set_name("Inspector");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue