YanCheng_Metrology/Assets/Scripts/Project/UI/UI_Panel/UI_TopTipPanel.cs

21 lines
693 B
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
public class UI_TopTipPanel : BasePanel
{
public void Init(string title, string content)
{
GetControl<TextMeshProUGUI>("Text_Title").text = title;
GetControl<TextMeshProUGUI>("Text_Content").text = content;
GetControl<TextMeshProUGUI>("Text_Content").GetComponent<ContentSizeFitter>().SetLayoutVertical();
var height = GetControl<TextMeshProUGUI>("Text_Content").rectTransform.sizeDelta.y + 60 + 40;
GetControl<Image>("Image_BackGround").rectTransform.sizeDelta = new Vector2(640 , height);
}
}