当前位置:网站首页>获取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;
}
边栏推荐
- Paper study -- accurate accounting of annual total runoff control rate considering the interannual variation characteristics of rainfall
- Campus errands wechat applet errands students with live new source code
- Jet hydrogen technology rushes to the scientific innovation board: SAIC Group is the major shareholder to raise 1.06 billion yuan
- Wei long updated the prospectus: the annual revenue of 4.8 billion founder liuweiping has a strong family color
- 广州期货正规吗?如果有人喊你用自己的手机登,帮忙开户,安全吗?
- Interview shock 61: tell me about MySQL transaction isolation level?
- Chinese garbled code output from idea output station
- 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
- I log in to the RDB database and prompt that the master account authorization is required. How do I know who to call?
- Laravel - composer installs the specified laravel version
猜你喜欢

synchronized 与多线程的哪些关系

Whitelabel Error Page访问

PostgreSql学习(基于菜鸟课程)

CKS CKA CKAD 将终端更改为远程桌面

VQA needs not only pictures, but also external knowledge! University of Washington & Microsoft proposed revive, using gpt-3 and wikidata to help answer questions

MCS:离散随机变量——Hyper Geometric分布

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

Jet hydrogen technology rushes to the scientific innovation board: SAIC Group is the major shareholder to raise 1.06 billion yuan

PostgreSQL learning (based on rookie course)

阿尔兹海默病智能诊断
随机推荐
熊市慢慢,Bit.Store提供稳定Staking产品助你穿越牛熊
Unity C# 基础复习29——泛型委托(P451)
Explanation on deployment and establishment of decentraland process
Query function of Excel vlookup
关于项目采购管理,这些你需要知道
Interview shock 61: tell me about MySQL transaction isolation level?
How word automatically generates directories
第五届中国软件开源创新大赛 | openGauss赛道直播培训
[Verilog quick start of Niuke online question series] ~ shift operation and multiplication
Paper study -- accurate accounting of annual total runoff control rate considering the interannual variation characteristics of rainfall
Informatics Olympiad all in one 2062: movie tickets
MCS:多元随机变量——多项式分布
How bad can a programmer be?
JS 会有变量提升和函数提升
驱动器实际运用案例
Redis installation in windows and Linux Environment
Class template case - array class encapsulation
Unity C# 基础复习27——委托示例(P448)
China arsenic trioxide industry research and future forecast report (2022 Edition)
异步神器CompletableFuture