protected RadarFill CreateFillObject(GameObject conatiner) { GameObject obj = ChartCommon.CreateCanvasChartItem(); ChartCommon.HideObject(obj, hideHierarchy); obj.AddComponent <ChartItem>(); obj.AddComponent <CanvasRenderer>(); RadarFill fill = obj.AddComponent <RadarFill>(); obj.transform.SetParent(conatiner.transform, false); obj.transform.localScale = new Vector3(1f, 1f, 1f); obj.transform.localPosition = Vector3.zero; obj.transform.localRotation = Quaternion.identity; return(fill); }
protected override GameObject CreateCategoryObject(Vector3[] path, int category) { Vector3[] newPath = new Vector3[path.Length + 1]; path.CopyTo(newPath, 0); newPath[path.Length] = path[0]; path = newPath; List <CanvasLines.LineSegement> seg = new List <CanvasLines.LineSegement>(); seg.Add(new CanvasLines.LineSegement(path)); RadarChartData.CategoryData cat = ((IInternalRadarData)DataSource).getCategoryData(category); GameObject container = ChartCommon.CreateChartItem(); ChartCommon.HideObject(container, hideHierarchy); container.transform.SetParent(transform, false); container.transform.localScale = new Vector3(1f, 1f, 1f); container.transform.localPosition = Vector3.zero; container.transform.localRotation = Quaternion.identity; if (cat.FillMaterial != null) { RadarFill fill = CreateFillObject(container); fill.material = cat.FillMaterial; fill.SetPath(path, Radius); } if (cat.LineMaterial != null && cat.LineThickness > 0) { CanvasLines lines = CreateLinesObject(container); lines.material = cat.LineMaterial; lines.Thickness = cat.LineThickness; lines.SetHoverPrefab(cat.LineHover); lines.SetLines(seg); } if (cat.PointMaterial != null && cat.PointSize > 0f) { CanvasLines points = CreateLinesObject(container); points.material = cat.PointMaterial; points.MakePointRender(cat.PointSize); points.SetHoverPrefab(cat.PointHover); points.SetLines(seg); string name = cat.Name; points.Hover += (int arg1, int t, object d, Vector2 arg2) => Points_Hover(name, arg1, arg2); points.Leave += () => Points_Leave(name); points.Click += (int arg1, int t, object d, Vector2 arg2) => Points_Click(name, arg1, arg2); } if (mCategoryLabels != null && mCategoryLabels.isActiveAndEnabled) { for (int i = 0; i < path.Length - 1; i++) { string group = DataSource.GetGroupName(i); double val = DataSource.GetValue(cat.Name, group); Vector3 labelPos = path[i]; Vector3 dir = labelPos.normalized; labelPos += dir * mCategoryLabels.Seperation; labelPos += new Vector3(mCategoryLabels.Location.Breadth, 0f, mCategoryLabels.Location.Depth); int fractionDigits = 2; if (mItemLabels != null) { fractionDigits = mItemLabels.FractionDigits; } string toSet = mCategoryLabels.TextFormat.Format(ChartAdancedSettings.Instance.FormatFractionDigits(fractionDigits, val, CustomNumberFormat), cat.Name, group); BillboardText billboard = ChartCommon.CreateBillboardText(null, mCategoryLabels.TextPrefab, transform, toSet, labelPos.x, labelPos.y, labelPos.z, 0f, null, hideHierarchy, mCategoryLabels.FontSize, mCategoryLabels.FontSharpness); TextController.AddText(billboard); AddBillboardText(cat.Name, billboard); } } return(container); }