public static ChartText AddTextObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, TextStyle textStyle, ComponentTheme theme) { GameObject txtObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); txtObj.transform.localEulerAngles = new Vector3(0, 0, textStyle.rotate); var chartText = new ChartText(); #if dUI_TextMeshPro RemoveComponent <Text>(txtObj); chartText.tmpText = GetOrAddComponent <TextMeshProUGUI>(txtObj); chartText.tmpText.font = textStyle.tmpFont == null ? theme.tmpFont : textStyle.tmpFont; chartText.tmpText.fontStyle = textStyle.tmpFontStyle; chartText.tmpText.alignment = textStyle.tmpAlignment; chartText.tmpText.richText = true; chartText.tmpText.raycastTarget = false; chartText.tmpText.enableWordWrapping = false; #else chartText.text = GetOrAddComponent <Text>(txtObj); chartText.text.font = textStyle.font == null ? theme.font : textStyle.font; chartText.text.fontStyle = textStyle.fontStyle; chartText.text.alignment = textStyle.alignment; chartText.text.horizontalOverflow = HorizontalWrapMode.Overflow; chartText.text.verticalOverflow = VerticalWrapMode.Overflow; chartText.text.supportRichText = true; chartText.text.raycastTarget = false; #endif chartText.SetColor(textStyle.GetColor(theme.textColor)); chartText.SetFontSize(textStyle.fontSize > 0 ? textStyle.fontSize : theme.fontSize); chartText.SetText("Text"); chartText.SetLineSpacing(textStyle.lineSpacing); RectTransform rect = GetOrAddComponent <RectTransform>(txtObj); rect.localPosition = Vector3.zero; rect.sizeDelta = sizeDelta; rect.anchorMin = anchorMin; rect.anchorMax = anchorMax; rect.pivot = pivot; return(chartText); }