39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UI_TopTipPanel : BasePanel
|
|
{
|
|
/// <summary>
|
|
/// 面板显示后几秒后消失
|
|
/// </summary>
|
|
private float disappear = 5f;
|
|
public void Init(string title, string content, bool isHide)
|
|
{
|
|
disappear = 5f;
|
|
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);
|
|
if (isHide)
|
|
Hide();
|
|
}
|
|
/// <summary>
|
|
/// 面板消失
|
|
/// </summary>
|
|
private void Hide()
|
|
{
|
|
StopCoroutine(HideAsync());
|
|
StartCoroutine(HideAsync());
|
|
}
|
|
private IEnumerator HideAsync()
|
|
{
|
|
yield return new WaitForSeconds(disappear);
|
|
UIManager.Instance.HidePanel<UI_TopTipPanel>();
|
|
}
|
|
}
|