您现在的位置是:首页 >技术交流 >unity inputField计算文本高度网站首页技术交流
unity inputField计算文本高度
简介unity inputField计算文本高度
private float countTextHeight()
{
InputField inputField = talkBox.transform.GetComponent<InputField>();
TextGenerator m_TextGenerator = inputField.textComponent.cachedTextGenerator;
TextGenerationSettings settings = inputField.textComponent.GetGenerationSettings(new Vector2(inputField.GetComponent<RectTransform>().rect.width, 0));
settings.fontSize = playerInputTextSize;
settings.lineSpacing = 1;
settings.verticalOverflow = VerticalWrapMode.Overflow;
float height = m_TextGenerator.GetPreferredHeight(inputField.text, settings);
return height;
//inputField.GetComponent().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height); }
//return 1f;
}
风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。





U8W/U8W-Mini使用与常见问题解决
QT多线程的5种用法,通过使用线程解决UI主界面的耗时操作代码,防止界面卡死。...
stm32使用HAL库配置串口中断收发数据(保姆级教程)
分享几个国内免费的ChatGPT镜像网址(亲测有效)
Allegro16.6差分等长设置及走线总结