34 lines
763 B
C#
34 lines
763 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
public class CheckTextStrLength : MonoBehaviour
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public float with = 200;
|
|
private Text mailText;
|
|
RectTransform rect;
|
|
|
|
RectTransform imgRect;
|
|
void Start()
|
|
{
|
|
mailText = GetComponent<Text>();
|
|
rect = GetComponent<RectTransform>();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
float curWith = 0;
|
|
mailText.text = mailText.text;
|
|
if (mailText.preferredWidth < with)
|
|
curWith = mailText.preferredWidth;
|
|
else
|
|
curWith = with;
|
|
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, curWith);
|
|
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, mailText.preferredHeight);
|
|
}
|
|
}
|