From 8d3a5bc458d1a605d117bf97631e4501189d1c2a Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Mon, 12 Jul 2021 22:28:17 -0400 Subject: [PATCH] [3.x] Add generics to PackedScene instance --- binding_generator.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/binding_generator.py b/binding_generator.py index da4bb61c..0cc0fad0 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -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 ") + source.append("\tT *instance(const int64_t edit_state = 0) const {") + source.append("\t\treturn Object::cast_to(instance(edit_state));") + source.append("\t}") + + source.append("};") + source.append("") + + source.append("template <>") + source.append("inline Node *PackedScene::instance(const int64_t edit_state) const {") + source.append("\treturn instance(edit_state);") + source.append("}") + source.append("") else: source.append("};") source.append("")