计算字体宽度及Text组件的自适应怎么设置
发表于:2024-10-15 作者:千家信息网编辑
千家信息网最后更新 2024年10月15日,今天小编给大家分享一下计算字体宽度及Text组件的自适应怎么设置的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,
千家信息网最后更新 2024年10月15日计算字体宽度及Text组件的自适应怎么设置
今天小编给大家分享一下计算字体宽度及Text组件的自适应怎么设置的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ChatView : MonoBehaviour
{
#region RectTransformprivate RectTransform ChatContent;#endregion#region GameObjectprivate GameObject LeftChatObj;private GameObject RightChatObj;#endregionprivate void Awake(){ InitGetComponent();}private void Start(){ Test();}private void InitGetComponent(){ #region RectTransform ChatContent = transform.Find("ChatPanel/ScrollView/Viewport/ChatContent").GetComponent(); #endregion #region GameObject LeftChatObj = Resources.Load ("Info/LeftChatInfo"); RightChatObj = Resources.Load ("Info/RightChatInfo"); #endregion}//测试方法private void Test(){ ChatInfo info1 = Instantiate(LeftChatObj, ChatContent).GetComponent (); ChatInfo info2 = Instantiate(RightChatObj, ChatContent).GetComponent (); // info1.SetChatText("椅子在异乡,树叶有翅膀,椅子在异乡,树叶有翅膀,椅子在异乡,树叶有翅膀"); info2.SetChatText("斯人如彩虹,遇上方知有,斯人如彩虹,遇上方知有,斯人如彩虹,遇上方知有,斯人如彩虹,遇上方知有,斯人如彩虹,遇上方知有"); UpdateLayout();}private void UpdateLayout(){ UITools.Instance.UpdateLayout(ChatContent);}
}
public class ChatInfo : MonoBehaviour
{
#region RectTransformprivate RectTransform RtChatContentText;private RectTransform RtBgEmpty;private RectTransform RtContentEmpty;private RectTransform RtSelf;#endregion#region Textprivate Text ChatContentText;#endregion#region float//字体总宽高private float m_FontTotalWidth = 0f;private float m_FontTotalHeight = 0f;//Text文本的宽高private float m_TextWidth = 0f;private float m_TextHeight = 0f;//Text背景图宽高private float m_TextBgWidth = 0f;private float m_TextBgHeight = 0f;#endregionprivate void Awake(){ InitGetComponent();}private void Start(){ //SetChatText("椅子在异乡,树叶有翅膀。椅子在异乡,树叶有翅膀。椅子在异乡,树叶有翅膀。椅子在异乡,树叶有翅膀。椅子在异乡,树叶有翅膀。"); //SetChatText("椅子在异乡,树叶有翅膀。");}private void InitGetComponent(){ #region RectTransform RtChatContentText = transform.Find("ContentEmpty/BgEmpty/ChatContentText").GetComponent(); RtBgEmpty = transform.Find("ContentEmpty/.........
以上就是"计算字体宽度及Text组件的自适应怎么设置"这篇文章的所有内容,感谢各位的阅读!相信大家阅读完这篇文章都有很大的收获,小编每天都会为大家更新不同的知识,如果还想学习更多的知识,请关注行业资讯频道。
异乡
树叶
椅子
翅膀
斯人
彩虹
知识
篇文章
字体
宽度
组件
内容
不同
很大
大部分
就是
文本
方法
更多
知识点
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
搞软件开发的是什么职业
球员数据库cba
连接数据库的三个包是
webcat怎么连接外部数据库
网络技术 专业校企合作
服务器顶级配置
四川蓝尔网络技术有限公司
linux中ftp如何进服务器
塔城互联网科技行情
温州盘古网络技术有限公司
江西多功能软件开发服务价格
我的世界允许服务器飞行
全国网络安全教育培训平台
教师网络安全责任
数据库表间级联关系
网络安全防总结
软件开发公司产品怎么推广
计算机网络技术的宣传语
阮承志 软件开发
自动网络技术开发行业
值得信赖的视频聊天软件开发
根据名字对数据库
潍坊ios软件开发企业
地方公安局网络安全活动方案
北京众意互联网科技有限公司
网络安全法要求用户提供
sun服务器维修电话
大学计算机数据库技术测验1
跟新数据库操作
关系数据库规范中的一系列范式