当前位置:网站首页>获取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;
}
边栏推荐
- MySQL中100w数据表比1000w数据表查询更快吗?
- 如果我在佛山,到哪里开户比较好?究竟网上开户是否安全么?
- 知识点:PCB线路板布线都有哪些诀窍?
- EXCEL的查询功能Vlookup
- const用法精讲
- You need to know about project procurement management
- render后续来了,封装一个表单往表格中添加数据
- Informatics Olympiad all in one 1194: mobile route
- Research Report on research and development prospect of China's urea dioxide industry (2022 Edition)
- 关于项目采购管理,这些你需要知道
猜你喜欢

论文学习——考虑场次降雨年际变化特征的年径流总量控制率准确核算

EMC surge protection and decoupling design

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

揭秘百度智能测试在测试自动执行领域实践

EMC-浪涌防护及退耦设计

Explanation on deployment and establishment of decentraland process

MCS:离散随机变量——几何分布

FIFO implementation with single port RAM

云上第一课 | 建个小破站有多简单?云计算老司机带你一小时搞定

Deploy redis sentry in k8s
随机推荐
ROS 笔记(10)— launch 文件启动
Are the top ten domestic securities companies safe?
How does a two character name become a three character name with spaces
MCS:离散随机变量——Hyper Geometric分布
熊市慢慢,Bit.Store提供稳定Staking产品助你穿越牛熊
If I am in Foshan, where can I open an account? Is it safe to open an account online?
EXCEL的查询功能Vlookup
June 27 talk SofiE
中国软冰淇淋市场预测与投资前景研究报告(2022版)
华曙高科冲刺科创板:拟募资6.6亿 实控人许小曙父子均为美国籍
kubernetes Unable to connect to the server: x509: certificate has expired or is not yet valid
. Net program configuration file operation (INI, CFG, config)
Analysis of constant current source circuit composed of two NPN tubes
Illustration of Ctrip quarterly report: net revenue of RMB 4.1 billion has been "halved" compared with that before the outbreak
信息学奥赛一本通1002:输出第二个整数
Chapter 11 of canvas canvas status
Chapter 5 text operation of canvas
PostgreSql学习(基于菜鸟课程)
I log in to the RDB database and prompt that the master account authorization is required. How do I know who to call?
[Verilog quick start of Niuke online question series] ~ shift operation and multiplication