You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
keep default exported script values unless overriden, closes #8127
(cherry picked from commit 475e8b28b2)
This commit is contained in:
committed by
Rémi Verschelde
parent
17b04adcc3
commit
c1b6301050
@@ -277,8 +277,23 @@ ScriptDebugger::ScriptDebugger() {
|
||||
bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_value) {
|
||||
|
||||
if (values.has(p_name)) {
|
||||
Variant defval;
|
||||
if (script->get_property_default_value(p_name, defval)) {
|
||||
if (defval == p_value) {
|
||||
values.erase(p_name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
values[p_name] = p_value;
|
||||
return true;
|
||||
} else {
|
||||
Variant defval;
|
||||
if (script->get_property_default_value(p_name, defval)) {
|
||||
if (defval != p_value) {
|
||||
values[p_name] = p_value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -288,12 +303,22 @@ bool PlaceHolderScriptInstance::get(const StringName &p_name, Variant &r_ret) co
|
||||
r_ret = values[p_name];
|
||||
return true;
|
||||
}
|
||||
|
||||
Variant defval;
|
||||
if (script->get_property_default_value(p_name, defval)) {
|
||||
r_ret = defval;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PlaceHolderScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
|
||||
|
||||
for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
|
||||
PropertyInfo pinfo = E->get();
|
||||
if (!values.has(pinfo.name)) {
|
||||
pinfo.usage |= PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE;
|
||||
}
|
||||
p_properties->push_back(E->get());
|
||||
}
|
||||
}
|
||||
@@ -333,6 +358,14 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c
|
||||
|
||||
if (!new_values.has(E->key()))
|
||||
to_remove.push_back(E->key());
|
||||
|
||||
Variant defval;
|
||||
if (script->get_property_default_value(E->key(), defval)) {
|
||||
//remove because it's the same as the default value
|
||||
if (defval == E->get()) {
|
||||
to_remove.push_back(E->key());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (to_remove.size()) {
|
||||
|
||||
Reference in New Issue
Block a user