From 9f6c0c6eaef754f2049ee536c5b38bfdc65fbd08 Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Fri, 9 Mar 2018 21:16:08 +0200 Subject: Duplicate Arrays and Dictionaries when instancing scene in editor Also, add deep (=false) parameter to Array.duplicate and Dictionary.duplicate Fixes #13971 --- core/variant_op.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'core/variant_op.cpp') diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 97b469861c..8d30305194 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -3415,6 +3415,19 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { return Variant(); } +Variant Variant::duplicate(bool deep) const { + switch (type) { + // case OBJECT: + // return operator Object *()->duplicate(); + case DICTIONARY: + return operator Dictionary().duplicate(deep); + case ARRAY: + return operator Array().duplicate(deep); + default: + return *this; + } +} + void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst) { if (a.type != b.type) { if (a.is_num() && b.is_num()) { -- cgit v1.2.3