Exemplo n.º 1
0
 public bool SetText(string text)
 {
     if (m_LabelRect == null)
     {
         return(false);
     }
     if (m_LabelText != null && !m_LabelText.GetText().Equals(text))
     {
         m_LabelText.SetText(text);
         if (m_LabelAutoSize)
         {
             var newSize = string.IsNullOrEmpty(text) ? Vector2.zero :
                           new Vector2(m_LabelText.GetPreferredWidth() + m_LabelPaddingLeftRight * 2,
                                       m_LabelText.GetPreferredHeight() + m_LabelPaddingTopBottom * 2);
             var sizeChange = newSize.x != m_LabelRect.sizeDelta.x || newSize.y != m_LabelRect.sizeDelta.y;
             if (sizeChange)
             {
                 m_LabelRect.sizeDelta = newSize;
                 AdjustIconPos();
             }
             return(sizeChange);
         }
         AdjustIconPos();
         if (m_AutoHideIconWhenLabelEmpty && isIconActive)
         {
             ChartHelper.SetActive(m_IconImage.gameObject, !string.IsNullOrEmpty(text));
         }
     }
     return(false);
 }
Exemplo n.º 2
0
 public bool SetText(string text)
 {
     if (m_LabelRect == null)
     {
         return(false);
     }
     if (m_LabelText != null && !m_LabelText.GetText().Equals(text))
     {
         m_LabelText.SetText(text);
         if (m_LabelAutoSize)
         {
             var newSize = string.IsNullOrEmpty(text) ? Vector2.zero :
                           new Vector2(m_LabelText.GetPreferredWidth() + m_LabelPaddingLeftRight * 2,
                                       m_LabelText.GetPreferredHeight() + m_LabelPaddingTopBottom * 2);
             var sizeChange = newSize.x != m_LabelRect.sizeDelta.x || newSize.y != m_LabelRect.sizeDelta.y;
             if (sizeChange)
             {
                 m_LabelRect.sizeDelta  = newSize;
                 m_ObjectRect.sizeDelta = newSize;
             }
             return(sizeChange);
         }
     }
     return(false);
 }
Exemplo n.º 3
0
 public bool SetContent(string content)
 {
     if (m_Text != null && !m_Text.GetText().Equals(content))
     {
         m_Text.SetText(content);
         if (m_LabelAutoSize)
         {
             var newSize = string.IsNullOrEmpty(content) ? Vector2.zero :
                           new Vector2(m_Text.GetPreferredWidth(), m_Text.GetPreferredHeight());
             var sizeChange = newSize.x != m_TextRect.sizeDelta.x || newSize.y != m_TextRect.sizeDelta.y;
             if (sizeChange)
             {
                 m_TextRect.sizeDelta           = newSize;
                 m_TextRect.anchoredPosition3D  = new Vector3(m_LabelPaddingLeftRight, 0);
                 m_TextBackgroundRect.sizeDelta = new Vector2(m_Text.GetPreferredWidth() + m_LabelPaddingLeftRight * 2,
                                                              m_Text.GetPreferredHeight() + m_LabelPaddingTopBottom * 2 - 4);
                 m_Rect.sizeDelta = new Vector3(width, height);
             }
             return(sizeChange);
         }
     }
     return(false);
 }