小技巧总结

Text篇

挂载ContentSizeFitter   可以动态改变Text框大小

提前获取文本宽度方法:

public int GetTextLength(Text text, string str)
    {
        Font font = text.font;
        int fontsize = text.fontSize;
        font.RequestCharactersInTexture(str, fontsize, text.fontStyle);
        CharacterInfo characterInfo;
        int width = 0;
        for(int i = 0; i < str.Length; i++){
            font.GetCharacterInfo(str[i], out characterInfo, fontsize);
            width += characterInfo.advance;
        }
        return width;
    }

Image篇

彩色转黑白经验值:Gray = R*0.299 + G*0.587 + B*0.114

原文地址:https://www.cnblogs.com/zhenlong/p/6086362.html