RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
计算字体宽度及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组件的自适应怎么设置”这篇文章的所有内容,感谢各位的阅读!相信大家阅读完这篇文章都有很大的收获,小编每天都会为大家更新不同的知识,如果还想学习更多的知识,请关注创新互联行业资讯频道。


本文题目:计算字体宽度及Text组件的自适应怎么设置
浏览路径:http://scyingshan.cn/article/ispdoj.html