void CreateLabels()
{
float y = 0; //TODO
foreach (Transform child in gameObject.transform)
{
if (child.name.StartsWith("PieLabel")
|| child.name == "Title")
{
Transform.Destroy(child.gameObject);
}
}
if (Title != "")
CreateLabel(
"Title",
Title,
new Vector3(0, Height / 2+ 0.15f, 0),
24,
Color.black,
133,
TextAlignment.Center,
TextAnchor.MiddleCenter);
for (int i = 0; i < datas.Count; i++)
{
if (!datas[i].ContainsKey("label")) break;
CreateLabel(
"PieLabel" + i,
(string) datas[i]["label"] + ": ",
new Vector3(-Width/2, -Height/2 - ((i+1)*0.15f), 0),
15,
(Color32)datas[i]["color1"],
133,
TextAlignment.Left,
TextAnchor.UpperLeft);
CreateLabel(
"PieLabelValue" + i,
((float)datas[i]["value"]).ToString("N2") + " (" + (100.0f * (float)datas[i]["percent"]).ToString("00.00") + "%)",
new Vector3(Width/2, -Height/2 - ((i+1)*0.15f), 0),
15,
Color.black,
133,
TextAlignment.Right,
TextAnchor.UpperRight);
}
}