From 870414bb0df61e27ddedf9a90948d0bb2cf9dd82 Mon Sep 17 00:00:00 2001 From: Dmitry Maganov Date: Mon, 29 Oct 2018 11:59:25 +0300 Subject: [PATCH] Fix closing --- Assets/SVGMeshUnity/Runtime/SVGData.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Assets/SVGMeshUnity/Runtime/SVGData.cs b/Assets/SVGMeshUnity/Runtime/SVGData.cs index ab786ca..dc590b1 100644 --- a/Assets/SVGMeshUnity/Runtime/SVGData.cs +++ b/Assets/SVGMeshUnity/Runtime/SVGData.cs @@ -18,7 +18,7 @@ public class SVGData internal List Curves = new List(); - private Vector2 Start; + private Nullable Start; private Vector2 Current; private Nullable Bezier; private Nullable Quad; @@ -26,7 +26,7 @@ public class SVGData public void Clear() { Curves.Clear(); - Start = Vector2.zero; + Start = null; Current = Vector2.zero; Bezier = null; Quad = null; @@ -78,6 +78,7 @@ private void CurveInternal(Vector2 inControl, Vector2 outControl, Vector2 v) InControl = inControl, OutControl = outControl, }); + Start = Start == null ? Current : Start; Current = v; Bezier = null; Quad = null; @@ -211,7 +212,12 @@ public void LineVerticalRelative(float y) public void Close() { - Line(Start); + if (Start != null && Start != Current) + { + Line(Start.Value); + } + + Start = null; } @@ -391,12 +397,12 @@ public void Path(string data) private bool LoadCommand(string command, string type, float[] args, int numArgs, ref int argsIndex) { - if (argsIndex == numArgs) + var len = ArgumentLengthes[type]; + + if (argsIndex == numArgs && len > 0) { return true; } - - var len = ArgumentLengthes[type]; if (argsIndex + len > numArgs) { @@ -469,6 +475,8 @@ private bool LoadCommand(string command, string type, float[] args, int numArgs, break; } + if (len == 0) return true; + argsIndex += len; return false;