当前位置:网站首页>Get the width of text component content
Get the width of text component content
2022-06-29 15:05:00 【Sunshine in front of heart】
Text The component already has text content
// The required length of a line of text
Debug.Log(text.preferredWidth);// According to the text Recommended preferred width
Text Component has no text content Get width in advance
int CalucalateTextContenWidth(Font font, string content, int fontSize, FontStyle fontStyle)
{
font.RequestCharactersInTexture(content, fontSize, fontStyle);
int width = 0;
CharacterInfo characterInfo;
// Read the information of each character
for (int i = 0; i < content.Length; i++)
{
font.GetCharacterInfo(content[i], out characterInfo, fontSize, fontStyle);
width += characterInfo.advance;
}
return width;
}
边栏推荐
- Evaluation index of high concurrency software (website, server interface)
- 知识点:PCB线路板布线都有哪些诀窍?
- You need to know about project procurement management
- Konva series Tutorial 4: drawing attributes
- 又拍云 Redis 的改进之路
- 信息学奥赛一本通1002:输出第二个整数
- 微信公众号—菜单
- Slow bear market, bit Store provides stable stacking products to help you cross the bull and bear
- PostgreSQL learning (based on rookie course)
- 文本预处理库spaCy的基本使用(快速入门)
猜你喜欢

SOFARegistry 源码|数据同步模块解析

Configuration tutorial for swagger2

Slow bear market, bit Store provides stable stacking products to help you cross the bull and bear

知识点:PCB线路板布线都有哪些诀窍?

华为软件测试笔试真题之变态逻辑推理题【二】华为爆火面试题

第九章 APP项目测试(此章完结)

Uniapp problem list and experience

What is the relationship between synchronized and multithreading

宜明昂科冲刺港股:年内亏损7.3亿 礼来与阳光人寿是股东

阿尔兹海默病智能诊断
随机推荐
知识点:PCB线路板布线都有哪些诀窍?
Can futures accounts be opened offline? Is it safe to open an account online?
Yi Ming ang Ke rushed to Hong Kong shares: loss of 730million in the year Lilly and sunshine life insurance were shareholders
获取Text组件内容的宽度
Unity C# 基础复习27——委托示例(P448)
信息学奥赛一本通1002:输出第二个整数
知乎热议:一个程序员的水平能差到什么程度?
If I am in Foshan, where can I open an account? Is it safe to open an account online?
June 27 talk SofiE
Chinese garbled code output from idea output station
Netease strict selection offline data warehouse quality construction practice
BioVendor游离轻链(κ和λ)Elisa 试剂盒的化学性质
ROS notes (10) - Launch file startup
微信公众号—菜单
Unity C# 基础复习29——泛型委托(P451)
我登录RDB的数据库,提示需要主账号授权,这个我怎么知道该找谁?
文本预处理库spaCy的基本使用(快速入门)
word如何自动生成目录
墨滴排版
Trigonometric function corresponding to drawing circle on plane coordinate