From eb8952e995a401f3ca8c8007b5fca1a384f626cc Mon Sep 17 00:00:00 2001 From: Xavier Sellier Date: Thu, 30 Nov 2017 21:53:50 -0500 Subject: [PATCH] Vector2 and Vector3 are not properly parsed This commit should solve https://github.com/godotengine/godot/issues/13425 It has been tested manually and it works like a charm --- core/globals.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/globals.cpp b/core/globals.cpp index d7a96dbe7e..f3ba73882b 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -169,6 +169,7 @@ bool Globals::_get(const StringName &p_name, Variant &r_ret) const { if (!props.has(p_name)) return false; + r_ret = props[p_name].variant; return true; } @@ -700,9 +701,15 @@ static Variant _decode_variant(const String &p_string) { } if (str.find(",") != -1) { //vector2 or vector3 - Vector farr = str.split_floats(",", true); + // Since the data could be stored as Vector2(0, 0) + // We need to first remove any string from the data. + // To do that, we split the data using '(' as delimiter + // and keep the last element only. + // Then using the "split_floats" function should work like a charm + Vector sarr = str.split("(", true); + Vector farr = sarr[sarr.size() - 1].split_floats(",", true); if (farr.size() == 2) { - return Point2(farr[0], farr[1]); + return Vector2(farr[0], farr[1]); } if (farr.size() == 3) { return Vector3(farr[0], farr[1], farr[2]);