private void InitTitle(Title title) { title.OnChanged(); var anchorMin = title.location.runtimeAnchorMin; var anchorMax = title.location.runtimeAnchorMax; var pivot = title.location.runtimePivot; var titleObject = ChartHelper.AddObject(s_TitleObjectName + title.index, transform, anchorMin, anchorMax, pivot, m_ChartSizeDelta); title.gameObject = titleObject; title.painter = null; title.refreshComponent = delegate() { if (titleObject == null) { return; } title.OnChanged(); anchorMin = title.location.runtimeAnchorMin; anchorMax = title.location.runtimeAnchorMax; pivot = title.location.runtimePivot; title.textStyle.UpdateAlignmentByLocation(title.location); title.subTextStyle.UpdateAlignmentByLocation(title.location); var fontSize = title.textStyle.GetFontSize(theme.title); ChartHelper.UpdateRectTransform(titleObject, anchorMin, anchorMax, pivot, new Vector2(chartWidth, chartHeight)); var titlePosition = GetTitlePosition(title); var subTitlePosition = -new Vector3(0, fontSize + title.itemGap, 0); var titleWid = chartWidth; titleObject.transform.localPosition = titlePosition; titleObject.hideFlags = chartHideFlags; ChartHelper.HideAllObject(titleObject); var titleText = ChartHelper.AddTextObject(s_TitleObjectName, titleObject.transform, anchorMin, anchorMax, pivot, new Vector2(titleWid, fontSize), title.textStyle, theme.title); titleText.SetActive(title.show); titleText.SetLocalPosition(Vector3.zero + title.textStyle.offsetv3); titleText.SetText(title.text); var subText = ChartHelper.AddTextObject(s_SubTitleObjectName, titleObject.transform, anchorMin, anchorMax, pivot, new Vector2(titleWid, title.subTextStyle.GetFontSize(theme.subTitle)), title.subTextStyle, theme.subTitle); subText.SetActive(title.show && !string.IsNullOrEmpty(title.subText)); subText.SetLocalPosition(subTitlePosition + title.subTextStyle.offsetv3); subText.SetText(title.subText); }; title.refreshComponent(); }
private void InitTitle() { m_Title.OnChanged(); TextAnchor anchor = m_Title.location.textAnchor; Vector2 anchorMin = m_Title.location.anchorMin; Vector2 anchorMax = m_Title.location.anchorMax; Vector2 pivot = m_Title.location.pivot; Vector3 titlePosition = m_Title.location.GetPosition(chartWidth, chartHeight); Vector3 subTitlePosition = -new Vector3(0, m_Title.textFontSize + m_Title.itemGap, 0); float titleWid = chartWidth; var titleObject = ChartHelper.AddObject(s_TitleObjectName, transform, anchorMin, anchorMax, pivot, new Vector2(chartWidth, chartHeight)); titleObject.transform.localPosition = titlePosition; ChartHelper.HideAllObject(titleObject); Text titleText = ChartHelper.AddTextObject(s_TitleObjectName, titleObject.transform, m_ThemeInfo.font, m_ThemeInfo.titleTextColor, anchor, anchorMin, anchorMax, pivot, new Vector2(titleWid, m_Title.textFontSize), m_Title.textFontSize); titleText.alignment = anchor; titleText.gameObject.SetActive(m_Title.show); titleText.transform.localPosition = Vector2.zero; titleText.text = m_Title.text.Replace("\\n", "\n"); Text subText = ChartHelper.AddTextObject(s_TitleObjectName + "_sub", titleObject.transform, m_ThemeInfo.font, m_ThemeInfo.titleTextColor, anchor, anchorMin, anchorMax, pivot, new Vector2(titleWid, m_Title.subTextFontSize), m_Title.subTextFontSize); subText.alignment = anchor; subText.gameObject.SetActive(m_Title.show && !string.IsNullOrEmpty(m_Title.subText)); subText.transform.localPosition = subTitlePosition; subText.text = m_Title.subText.Replace("\\n", "\n"); }
private void InitTitle() { m_Title.OnChanged(); TextAnchor anchor = m_Title.location.runtimeTextAnchor; Vector2 anchorMin = m_Title.location.runtimeAnchorMin; Vector2 anchorMax = m_Title.location.runtimeAnchorMax; Vector2 pivot = m_Title.location.runtimePivot; Vector3 titlePosition = GetTitlePosition(); Vector3 subTitlePosition = -new Vector3(0, m_Title.textStyle.fontSize + m_Title.itemGap, 0); float titleWid = chartWidth; var titleObject = ChartHelper.AddObject(s_TitleObjectName, transform, anchorMin, anchorMax, pivot, new Vector2(chartWidth, chartHeight)); titleObject.transform.localPosition = titlePosition; titleObject.hideFlags = chartHideFlags; ChartHelper.HideAllObject(titleObject); var textFont = TitleHelper.GetTextFont(title, themeInfo); var textColor = TitleHelper.GetTextColor(title, themeInfo); Text titleText = ChartHelper.AddTextObject(s_TitleObjectName, titleObject.transform, textFont, textColor, anchor, anchorMin, anchorMax, pivot, new Vector2(titleWid, m_Title.textStyle.fontSize), m_Title.textStyle.fontSize, m_Title.textStyle.rotate, m_Title.textStyle.fontStyle, m_Title.textStyle.lineSpacing); titleText.alignment = anchor; titleText.gameObject.SetActive(m_Title.show); titleText.transform.localPosition = Vector3.zero + m_Title.textStyle.offsetv3; titleText.text = m_Title.text.Replace("\\n", "\n"); var subTextFont = TitleHelper.GetSubTextFont(title, themeInfo); var subTextColor = TitleHelper.GetSubTextColor(title, themeInfo); Text subText = ChartHelper.AddTextObject(s_SubTitleObjectName, titleObject.transform, subTextFont, subTextColor, anchor, anchorMin, anchorMax, pivot, new Vector2(titleWid, m_Title.subTextStyle.fontSize), m_Title.subTextStyle.fontSize, m_Title.subTextStyle.rotate, m_Title.subTextStyle.fontStyle, m_Title.subTextStyle.lineSpacing); subText.alignment = anchor; subText.gameObject.SetActive(m_Title.show && !string.IsNullOrEmpty(m_Title.subText)); subText.transform.localPosition = subTitlePosition + m_Title.subTextStyle.offsetv3; subText.text = m_Title.subText.Replace("\\n", "\n"); }