In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Today Xiaobian to share with you the calculation of font width and Text component adaptive how to set the relevant knowledge points, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for everyone to refer to, I hope you read this article after some harvest, let's learn about it together.
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}//Test method private void Test(){ ChatInfo info1 = Instantiate (LeftChatObj, ChatContent).GetComponent(); ChatInfo info2 = Instantiate (RightChatObj, ChatContent).GetComponent(); // info1.SetChatText ("Chairs in foreign lands, leaves with wings, chairs in foreign lands, leaves with wings, chairs in foreign lands, leaves with wings"); info2.SetChatText ("People are like rainbows until they meet, people are like rainbows until they meet"); 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//total width of text private float m_FontTotalWidth = 0f;private float m_FontTotalHeight = 0f;//width and height of text private float m_TextWidth = 0f;private float m_TextHeight = 0f;//Text background image width height private float m_TextBgWidth = 0f;private float m_TextBgHeight = 0f;#endregionprivate void Awake(){ InitGetComponent();}private void Start(){ //SetChatText("Chairs in foreign land, leaves have wings. Chairs in foreign lands, leaves with wings. Chairs in foreign lands, leaves with wings. Chairs in foreign lands, leaves with wings. Chairs in foreign lands, leaves with wings. "); //SetChatText(" Chairs in foreign lands, leaves with wings. ");}private void InitGetComponent(){ #region RectTransform RtChatContentText = transform.Find("ContentEmpty/BgEmpty/ChatContentText").GetComponent(); RtBgEmpty = transform.Find("ContentEmpty/......... The above is "calculate font width and Text component adaptive how to set" all the content of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.