Add generics to PackedScene instance

Aaron Franke 2021-07-12 22:28:17 -04:00
parent bfdf55afd9
commit 736573a7f4
No known key found for this signature in database
GPG Key ID: 40A1750B977E56BF
1 changed files with 14 additions and 0 deletions

View File

@ -361,6 +361,20 @@ def generate_class_header(used_classes, c, use_template_get_node):
source.append("\treturn get_node_internal(path);")
source.append("}")
source.append("")
elif use_template_get_node and class_name == "PackedScene":
source.append("\ttemplate <class T = Node>")
source.append("\tT *instance(const int64_t edit_state = 0) const {")
source.append("\t\treturn Object::cast_to<T>(instance(edit_state));")
source.append("\t}")
source.append("};")
source.append("")
source.append("template <>")
source.append("inline Node *PackedScene::instance<Node>(const int64_t edit_state) const {")
source.append("\treturn instance(edit_state);")
source.append("}")
source.append("")
else:
source.append("};")
source.append("")