Merged in donnysobonny/unity-ui-extensions (pull request #56)

Master
pull/413/head
Donny Sutherland 2019-09-09 11:59:13 +00:00 committed by Simon Jackson
commit bc10ac6d57
1 changed files with 12 additions and 6 deletions

View File

@ -188,8 +188,7 @@ namespace UnityEngine.UI.Extensions
segments.Add (CreateLineCap (start, end, SegmentType.Start));
}
//segments.Add(CreateLineSegment(start, end, SegmentType.Full));
segments.Add (CreateLineSegment (start, end, SegmentType.Middle));
segments.Add(CreateLineSegment(start, end, SegmentType.Middle, segments.Count > 1 ? segments[segments.Count - 2] : null));
if (lineCaps) {
segments.Add (CreateLineCap (start, end, SegmentType.End));
@ -207,7 +206,6 @@ namespace UnityEngine.UI.Extensions
}
segments.Add (CreateLineSegment (start, end, SegmentType.Middle));
//segments.Add(CreateLineSegment(start, end, SegmentType.Full));
if (lineCaps && i == pointsToDraw.Length - 1) {
segments.Add (CreateLineCap (start, end, SegmentType.End));
@ -308,12 +306,20 @@ namespace UnityEngine.UI.Extensions
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;
var v1 = start - offset;
var v2 = start + offset;
Vector2 v1 = Vector2.zero;
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 v3 = end + offset;
var v4 = end - offset;
//Return the VDO with the correct uvs