fixed an issue with bezier curves where the segments of the generated mesh do not join up correctly

pull/413/head
Donny Sutherland 2019-09-01 13:31:59 +00:00
parent ccf9279626
commit f1697b4f91
1 changed files with 15 additions and 4 deletions

View File

@ -188,8 +188,9 @@ namespace UnityEngine.UI.Extensions
segments.Add (CreateLineCap (start, end, SegmentType.Start)); segments.Add (CreateLineCap (start, end, SegmentType.Start));
} }
segments.Add(CreateLineSegment(start, end, SegmentType.Middle, segments.Count > 1 ? segments[segments.Count - 2] : null));
//segments.Add(CreateLineSegment(start, end, SegmentType.Full)); //segments.Add(CreateLineSegment(start, end, SegmentType.Full));
segments.Add (CreateLineSegment (start, end, SegmentType.Middle)); //segments.Add (CreateLineSegment (start, end, SegmentType.Middle));
if (lineCaps) { if (lineCaps) {
segments.Add (CreateLineCap (start, end, SegmentType.End)); segments.Add (CreateLineCap (start, end, SegmentType.End));
@ -308,12 +309,22 @@ namespace UnityEngine.UI.Extensions
return null; return null;
} }
private UIVertex[] CreateLineSegment(Vector2 start, Vector2 end, SegmentType type) private UIVertex[] CreateLineSegment(Vector2 start, Vector2 end, SegmentType type, UIVertex[] previousVert = null)
{ {
Vector2 offset = new Vector2((start.y - end.y), end.x - start.x).normalized * lineThickness / 2; Vector2 offset = new Vector2((start.y - end.y), end.x - start.x).normalized * lineThickness / 2;
var v1 = start - offset; Vector2 v1 = Vector2.zero;
var v2 = start + offset; Vector2 v2 = Vector2.zero;
if (previousVert != null) {
v1 = new Vector2(previousVert[3].position.x, previousVert[3].position.y);
v2 = new Vector2(previousVert[2].position.x, previousVert[2].position.y);
} else {
v1 = start - offset;
v2 = start + offset;
}
//var v1 = start - offset;
//var v2 = start + offset;
var v3 = end + offset; var v3 = end + offset;
var v4 = end - offset; var v4 = end - offset;
//Return the VDO with the correct uvs //Return the VDO with the correct uvs