protected virtual void RenderStroke() { int pointsLength = points.Length; int pointsLengthMinusOne = pointsLength - 1; StrokeSegment[] segments = new StrokeSegment[pointsLengthMinusOne]; for (int i = 0; i < pointsLengthMinusOne; i++) { segments[i] = new StrokeSegment(points[i].GetPosition(), points[i + 1].GetPosition()); } meshFilter.sharedMesh = SVGLineUtils.StrokeMesh(segments, width, color, lineJoin, lineCap, mitterLimit, dashArray, dashOffset, closeLine, roundQuality); }
protected virtual void PrepareForRendering(Mesh sharedMesh, bool force) { if (sharedMesh == null) { return; } SVGPath[] shape = svgShape.shape; if (shape != null && shape.Length > 0) { int[][] submeshes = new int[sharedMesh.subMeshCount][]; int subMeshCount = sharedMesh.subMeshCount; int i, j; for (i = 0; i < subMeshCount; i++) { submeshes[i] = sharedMesh.GetTriangles(i); } Mesh[] meshes = new Mesh[shape.Length + 1]; for (i = 0; i < shape.Length; i++) { int pointsLength = shape[i].points.Length - 1; StrokeSegment[] segments = new StrokeSegment[pointsLength]; for (j = 0; j < pointsLength; j++) { segments[j] = new StrokeSegment(shape[i].points[j], shape[i].points[j + 1]); } meshes[i] = SVGLineUtils.StrokeMesh(segments, width, color, lineJoin, lineCap, mitterLimit, dashArray, dashOffset, closeLine, roundQuality); } CombineInstance[] combineInstances = new CombineInstance[meshes.Length]; for (i = 0; i < meshes.Length; i++) { combineInstances[i].mesh = meshes[i]; } sharedMesh.CombineMeshes(combineInstances, false, false); } }
public static Mesh CreateStrokeMesh(List <List <Vector2> > inputShapes, SVGPaintable paintable, ClosePathRule closePath = ClosePathRule.NEVER) { if (inputShapes == null || inputShapes.Count == 0 || paintable == null || paintable.strokeWidth <= 0f) { return(null); } List <StrokeSegment[]> segments = new List <StrokeSegment[]>(); for (int i = 0; i < inputShapes.Count; i++) { if (inputShapes[i] == null || inputShapes[i].Count < 2) { continue; } segments.Add(GetSegments(inputShapes[i])); } return(SVGLineUtils.StrokeMesh(segments, paintable.strokeWidth, GetStrokeColor(paintable), GetStrokeLineJoin(paintable.strokeLineJoin), GetStrokeLineCap(paintable.strokeLineCap), paintable.miterLimit, paintable.dashArray, paintable.dashOffset, closePath, SVGGraphics.roundQuality)); }