Vector3 AlignTextPosition(AlignedItemLabels labels, PieObject obj, out CanvasLines.LineSegement line, float modifiedRaidus) { line = null; float angle = obj.StartAngle + obj.AngleSpan * 0.5f; Vector3 position = new Vector3(labels.Seperation, labels.Location.Breadth, labels.Location.Depth); position = Quaternion.AngleAxis(angle, Vector3.forward) * position; float alignRadius = (modifiedRaidus + TorusRadius) * 0.5f; Vector3 atAngle = (Vector3)ChartCommon.FromPolar(angle, 1f); if (labels.Alignment == ChartLabelAlignment.Top) { alignRadius = Mathf.Max(modifiedRaidus, TorusRadius); Vector3 basePosition = atAngle * alignRadius; Vector3 end = basePosition + position; end -= (position.normalized * LineSpacingLink); Vector4[] arr = new Vector4[] { basePosition, end }; arr[0].w = -1f; arr[1].w = -1f; line = new CanvasLines.LineSegement(arr); } position += atAngle * alignRadius; return(position); }
private CanvasLines AddLineRenderer(GameObject topObject, CanvasLines.LineSegement line) { GameObject obj = ChartCommon.CreateCanvasChartItem(); obj.transform.SetParent(topObject.transform); obj.transform.localScale = new Vector3(1f, 1f, 1f); obj.transform.localPosition = new Vector3(0f, 0f, 0f); obj.transform.localRotation = Quaternion.identity; CanvasLines lines = obj.AddComponent<CanvasLines>(); lines.raycastTarget = false; var lst = new List<CanvasLines.LineSegement>(); lst.Add(line); lines.SetLines(lst); lines.Thickness = LineThicknessLink; lines.material = LineMaterialLink; return lines; }