using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
///
/// 封装一些常用得方法
///
public static class Utilitys
{
public static string Split(string info)
{
string[] parts = info.Split('_');
return parts.Length >= 3 ? string.Join("_", parts[2], parts[3]) : "";
}
///
/// 根据文字数量改变 背景 大小
///
///
public static void AdjustImageWidth(TextMeshProUGUI contentText, RectTransform _bg, float width, float height)
{
float preferredWidth = contentText.preferredWidth;
_bg.sizeDelta = new Vector2(preferredWidth + (contentText.text == "" ? 0 : width), _bg.sizeDelta.y);
contentText.GetComponent().sizeDelta = new Vector2(preferredWidth + (contentText.text == "" ? 0 : width), height);
}
}