获取字符串的像素长度

 public float GetPixelByStr(string str)
{
        float pixel = 0;
        for (int index = 0; index < str.Length; index++ )
        {
                float tempPixel = m_text.cachedTextGenerator.GetPreferredWidth(
                        str[index].Tostring(),
                        m_text.GetGenerationSettings(Vector2.zero));
                 pixel += tempPiexl;
        }
    return pixel;

}


QQ交流群:162136059

展开阅读全文

没有更多推荐了,返回首页