当前位置:网站首页>获取Text组件内容的宽度
获取Text组件内容的宽度
2022-06-29 14:45:00 【心前阳光】
Text组件已有文字内容
//文字显示一行的需要的长度
Debug.Log(text.preferredWidth);//根据文本内容 推荐首选宽度
Text组件没有文字内容 提前获取宽度
int CalucalateTextContenWidth(Font font, string content, int fontSize, FontStyle fontStyle)
{
font.RequestCharactersInTexture(content, fontSize, fontStyle);
int width = 0;
CharacterInfo characterInfo;
//读取每个字符的信息
for (int i = 0; i < content.Length; i++)
{
font.GetCharacterInfo(content[i], out characterInfo, fontSize, fontStyle);
width += characterInfo.advance;
}
return width;
}
边栏推荐
- Whitelabel Error Page访问
- Redis installation in windows and Linux Environment
- Illustration of Ctrip quarterly report: net revenue of RMB 4.1 billion has been "halved" compared with that before the outbreak
- 我 35 岁,可以转行当程序员吗?
- PostgreSql学习(基于菜鸟课程)
- Query function of Excel vlookup
- Wei long updated the prospectus: the annual revenue of 4.8 billion founder liuweiping has a strong family color
- go学习(四、面向接口)
- 【牛客网刷题系列 之 Verilog快速入门】~ 移位运算与乘法
- Const usage
猜你喜欢

Paper study -- accurate accounting of annual total runoff control rate considering the interannual variation characteristics of rainfall

MySQL的json 数组操作 json_array_append、json_array_insert

Build your own website (19)

openGauss社区成立SIG KnowledgeGraph

Trigonometric function corresponding to drawing circle on plane coordinate

What should phpcms do when it sends an upgrade request to the official website when it opens the background home page?

仿头条新闻资讯dz模板 Discuz新闻资讯商业版GBK模板源码

Uncover the secret! Pay attention to those machines under the membership system!

Chinese garbled code output from idea output station

【牛客网刷题系列 之 Verilog快速入门】~ 移位运算与乘法
随机推荐
Differences between @resource and @autowired annotations automatically injected:
EXCEL的查询功能Vlookup
网易严选离线数仓质量建设实践
CKS CKA CKAD 将终端更改为远程桌面
关于项目采购管理,这些你需要知道
知识点:PCB线路板布线都有哪些诀窍?
Heavyweight! The latest SCI impact factors were released in 2022, and the ranking of the three famous journals NCS and the top10 of domestic journals has changed (the latest impact factors in 2022 are
Const usage
Can futures accounts be opened offline? Is it safe to open an account online?
Deploy redis sentry in k8s
Uniapp problem list and experience
驱动器实际运用案例
华曙高科冲刺科创板:拟募资6.6亿 实控人许小曙父子均为美国籍
Evaluation index of high concurrency software (website, server interface)
Query function of Excel vlookup
wieshark抓包mysql协议简单分析
curl: (56) Recv failure: Connection reset by peer
Research Report on research and development prospect of China's urea dioxide industry (2022 Edition)
Laravel - composer installs the specified laravel version
高并发软件(网站,服务器端接口)的评价指标