using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace xcharts { public static class ChartUtils { private static float CRICLE_SMOOTHNESS = 1f; public static Text AddTextObject(string name, Transform parent, Font font, Color color, TextAnchor anchor,Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, int fontSize = 14) { GameObject txtObj; if (parent.Find(name)) { txtObj = parent.Find(name).gameObject; txtObj.SetActive(true); txtObj.transform.localPosition = Vector3.zero; } else { txtObj = new GameObject(); txtObj.name = name; txtObj.transform.parent = parent; txtObj.transform.localScale = Vector3.one; txtObj.transform.localPosition = Vector3.zero; txtObj.AddComponent(); } Text txt = txtObj.GetComponent(); txt.font = font; txt.fontSize = fontSize; txt.text = "Text"; txt.alignment = anchor; txt.horizontalOverflow = HorizontalWrapMode.Overflow; txt.verticalOverflow = VerticalWrapMode.Overflow; txt.color = color; txtObj.GetComponent().alignment = anchor; RectTransform rect = txtObj.GetComponent(); rect.sizeDelta = sizeDelta; rect.anchorMin = anchorMin; rect.anchorMax = anchorMax; rect.pivot = pivot; rect.localPosition = Vector3.zero; return txtObj.GetComponent(); } public static Button AddButtonObject(string name, Transform parent, Font font,Color color, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta) { GameObject btnObj; if (parent.Find(name)) { btnObj = parent.Find(name).gameObject; btnObj.SetActive(true); } else { btnObj = new GameObject(); btnObj.name = name; btnObj.transform.parent = parent; btnObj.transform.localPosition = Vector3.zero; btnObj.transform.localScale = Vector3.one; btnObj.AddComponent(); btnObj.AddComponent