判断要显示的字符串是否超出Text组件的宽度,超出的话要用…代替
可以用Font的CharacterInfo获取字符的长度(UGUI)
private void SetText(Text tt, string str)
{
tt.font.RequestCharactersInTexture(str, tt.fontSize);
CharacterInfo info;
tt.font.GetCharacterInfo('.', out info);
float dotWidth = info.advance * 3;
float txtWidth = tt.rectTransform.rect.width;
StringBuilder sb = new StringBuilder();
for