コード例 #1
0
        public static Vector3 GetLastCharacterLocalPosition(this UITextmesh self)
        {
            self.ActivatingComponent();
            if (self.unity_uitextmesh.m_textInfo.characterInfo != null && self.unity_uitextmesh.m_textInfo.characterInfo.Length > 0)
            {
                var info = self.unity_uitextmesh.m_textInfo.characterInfo[self.unity_uitextmesh.m_textInfo.characterCount - 1];
                return(info.vertex_BR.position);
            }
            var rect = self.unity_uitextmesh.rectTransform.rect;

            return(new Vector3(-rect.width / 2, -rect.height / 2, 0));
        }
コード例 #2
0
 //当手动修改text的时候,需要将mono的i18textcomponent给禁用掉
 static void __DisableI18Component(this UITextmesh self, bool enable = false)
 {
     self.ActivatingComponent();
     if (self.unity_i18ncomp_touched != null)
     {
         self.unity_i18ncomp_touched.enabled = enable;
         if (!enable)
         {
             Log.Warning($"组件{self.GetGameObject().name}, text在逻辑层进行了修改,所以应该去掉去预设里面的I18N组件,否则会被覆盖");
         }
     }
 }
コード例 #3
0
 public static void OnLanguageChange(this UITextmesh self)
 {
     self.ActivatingComponent();
     if (self.__text_key != null)
     {
         if (I18NComponent.Instance.I18NTryGetText(self.__text_key, out var text) && self.keyParams != null)
         {
             text = string.Format(text, self.keyParams);
         }
         self.unity_uitextmesh.text = text;
     }
 }
コード例 #4
0
 public static void SetColor(this UITextmesh self, string colorStr)
 {
     if (!colorStr.StartsWith("#"))
     {
         colorStr = "#" + colorStr;
     }
     if (ColorUtility.TryParseHtmlString(colorStr, out var color))
     {
         self.ActivatingComponent();
         self.unity_uitextmesh.color = color;
     }
     else
     {
         Log.Info(colorStr);
     }
 }
コード例 #5
0
 public static string GetText(this UITextmesh self)
 {
     self.ActivatingComponent();
     return(self.unity_uitextmesh.text);
 }
コード例 #6
0
 public static void SetMaxVisibleCharacters(this UITextmesh self, int count)
 {
     self.ActivatingComponent();
     self.unity_uitextmesh.maxVisibleCharacters = count;
 }
コード例 #7
0
 public static int GetCharacterCount(this UITextmesh self)
 {
     self.ActivatingComponent();
     return(self.unity_uitextmesh.CharacterCount);
 }
コード例 #8
0
 public static void SetTextColor(this UITextmesh self, Color color)
 {
     self.ActivatingComponent();
     self.unity_uitextmesh.color = color;
 }