You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-18 14:21:41 +00:00
GDScript: read constants from parent scripts
This is needed to create export variables from enums defined in a parent class.
This commit is contained in:
@@ -811,6 +811,21 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
|
|||||||
expr = constant;
|
expr = constant;
|
||||||
bfn = true;
|
bfn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check parents for the constant
|
||||||
|
if (!bfn && cln->extends_file != StringName()) {
|
||||||
|
Ref<GDScript> parent = ResourceLoader::load(cln->extends_file);
|
||||||
|
if (parent.is_valid() && parent->is_valid()) {
|
||||||
|
Map<StringName, Variant> parent_constants;
|
||||||
|
parent->get_constants(&parent_constants);
|
||||||
|
if (parent_constants.has(identifier)) {
|
||||||
|
ConstantNode *constant = alloc_node<ConstantNode>();
|
||||||
|
constant->value = parent_constants[identifier];
|
||||||
|
expr = constant;
|
||||||
|
bfn = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bfn) {
|
if (!bfn) {
|
||||||
|
|||||||
Reference in New Issue
Block a user