-Ability to roll-back script-exported properties to their default value on the script, closes #2128

This commit is contained in:
Juan Linietsky 2016-01-02 20:17:31 -03:00
parent 61745855d0
commit 1597082c85
7 changed files with 160 additions and 49 deletions

View file

@ -1592,6 +1592,28 @@ void GDScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) {
}*/
#endif
bool GDScript::get_property_default_value(const StringName& p_property, Variant &r_value) const {
#ifdef TOOLS_ENABLED
//for (const Map<StringName,Variant>::Element *I=member_default_values.front();I;I=I->next()) {
// print_line("\t"+String(String(I->key())+":"+String(I->get())));
//}
const Map<StringName,Variant>::Element *E=member_default_values_cache.find(p_property);
if (E) {
r_value=E->get();
return true;
}
if (base_cache.is_valid()) {
return base_cache->get_property_default_value(p_property,r_value);
}
#endif
return false;
}
ScriptInstance* GDScript::instance_create(Object *p_this) {