1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-21 14:57:09 +00:00

get parent class fields when updating a CSharpScript's exports

This makes the fields viewable / editable in the inspector
This commit is contained in:
Carter Anderson
2017-10-04 22:49:59 -07:00
parent d938de67ff
commit 19df296351

View File

@@ -1201,8 +1201,6 @@ bool CSharpScript::_update_exports() {
exported_members_cache.clear(); exported_members_cache.clear();
exported_members_defval_cache.clear(); exported_members_defval_cache.clear();
const Vector<GDMonoField *> &fields = script_class->get_all_fields();
// We are creating a temporary new instance of the class here to get the default value // We are creating a temporary new instance of the class here to get the default value
// TODO Workaround. Should be replaced with IL opcodes analysis // TODO Workaround. Should be replaced with IL opcodes analysis
@@ -1226,6 +1224,11 @@ bool CSharpScript::_update_exports() {
return false; return false;
} }
GDMonoClass *top = script_class;
while (top && top != native) {
const Vector<GDMonoField *> &fields = top->get_all_fields();
for (int i = 0; i < fields.size(); i++) { for (int i = 0; i < fields.size(); i++) {
GDMonoField *field = fields[i]; GDMonoField *field = fields[i];
@@ -1235,6 +1238,9 @@ bool CSharpScript::_update_exports() {
String name = field->get_name(); String name = field->get_name();
StringName cname = name; StringName cname = name;
if (member_info.has(cname))
continue;
Variant::Type type = GDMonoMarshal::managed_to_variant_type(field->get_type()); Variant::Type type = GDMonoMarshal::managed_to_variant_type(field->get_type());
if (field->has_attribute(CACHED_CLASS(ExportAttribute))) { if (field->has_attribute(CACHED_CLASS(ExportAttribute))) {
@@ -1257,6 +1263,9 @@ bool CSharpScript::_update_exports() {
member_info[cname] = PropertyInfo(type, name, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_SCRIPT_VARIABLE); member_info[cname] = PropertyInfo(type, name, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_SCRIPT_VARIABLE);
} }
} }
top = top->get_parent_class();
}
} }
if (placeholders.size()) { if (placeholders.size()) {