Compare commits

...

2 Commits

Author SHA1 Message Date
Aaron Franke 63716a7c68
Merge 8d3a5bc458 into 07153d40e0 2024-10-28 01:01:52 -07:00
Aaron Franke 8d3a5bc458
[3.x] Add generics to PackedScene instance 2024-10-28 01:01:42 -07:00
1 changed files with 14 additions and 0 deletions

View File

@ -381,6 +381,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("")