Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions Assets/SVGMeshUnity/Runtime/SVGData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public class SVGData

internal List<Curve> Curves = new List<Curve>();

private Vector2 Start;
private Nullable<Vector2> Start;
private Vector2 Current;
private Nullable<Vector2> Bezier;
private Nullable<Vector2> Quad;

public void Clear()
{
Curves.Clear();
Start = Vector2.zero;
Start = null;
Current = Vector2.zero;
Bezier = null;
Quad = null;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -211,7 +212,12 @@ public void LineVerticalRelative(float y)

public void Close()
{
Line(Start);
if (Start != null && Start != Current)
{
Line(Start.Value);
}

Start = null;
}


Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down